View unanswered posts | View active topics It is currently Mon Jul 22, 2019 9:49 pm



Reply to topic  [ 13 posts ] 
 Changing aim angle during sharp aim 
Author Message
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post Changing aim angle during sharp aim
So Mehman posted this in the Epic Moments thread:

Image

Anybody have any idea how Mehman did this? I PM'd him but I'm honestly not sure what kind of response I'll get. I'm hoping maybe somebody else has an idea.

Just directly affecting aim angle doesn't really seem to work, since when you're in sharp aim mode the game seems to force the "proper" aim angle based on where your mouse is. Also I don't know if there's any way to force a new mouse position. So I have no idea how he worked around all this.

EDIT: UInputMan:SetMousePos is the trick, isn't it? Augh, why didn't I see that earlier...

Though, how do you get the current mouse position? Is it UInputMan:TrapMousePos? Or does that do something else?

Also, what if they're not using a mouse?


Mon Aug 22, 2011 5:16 pm
Profile YIM
Data Realms SUPER Elite
Data Realms SUPER Elite

Joined: Thu Jun 03, 2010 10:06 pm
Posts: 3717
Location: Over there.
Reply with quote
Post Re: Changing aim angle during sharp aim
It's really easy to do, but it doesn't normally work if you are using mouse aim. I suspect he's doing it full keyboard, hell, I could do this if I did it in full keyboard.

But yeah, you could change the mouse pos, or you can change the aim angle with SetAimAngle.


Mon Aug 22, 2011 6:08 pm
Profile
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post Re: Changing aim angle during sharp aim
Nonsequitorian wrote:
or you can change the aim angle with SetAimAngle.


I just said you can't do that. It works if you're not sharp aiming, but if you ARE sharp aiming, the game overrides any changes you try to make. At least, it does if you're using a mouse.

The trick here is to figure out how to cover all the bases. So if non-mouse control is covered by just directly affecting the aim angle, how does one handle the same thing with mouse control?

Maybe there's something I can do with Controller functions/attributes.


Mon Aug 22, 2011 6:39 pm
Profile YIM
Data Realms SUPER Elite
Data Realms SUPER Elite

Joined: Thu Jun 03, 2010 10:06 pm
Posts: 3717
Location: Over there.
Reply with quote
Post Re: Changing aim angle during sharp aim
Maybe he's using SetAimAngle and some trig to move the mouse pos to where it would be. But you'd still have to know what the mouse pos was.

EDIT: I'm pretty sure he's using something that checks the AimAngle, if he didn't, and just moved the mouse upwards, then the angle wouldn't change uniformly like it does in the gif.


Mon Aug 22, 2011 7:13 pm
Profile
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post Re: Changing aim angle during sharp aim
In looking into this and also in talking to cave cricket, I've learned some things. Namely, how sharp aim changing actually works in mouse mode. Apparently, what happens is that your mouse is always considered to be at (0, 0) at the beginning of every frame. Then any change in the mouse position in that frame is applied to the sharp aim. Then you go to the next frame and repeat. So basically the mouse is always considered "centered" in absolute screen coordinates, rather than scene coordinates. Cricket figured all that out.

So, what do we actually have to work with? Well first off, we've got UInputMan:SetMousePos(). Theoretically this could be used to set the mouse position in a frame, which would then cause the sharp aim to adjust itself accordingly before the position gets set back to 0,0 at the start of the next frame. Unfortuantely, I'm not entirely certain how to use it. The function takes a vector as the first argument, and a number as the second. Obviously that vector is the new mouse coordinates, but what the heck does that number represent? Whenever I try to use the function, it doesn't seem to do anything at all, no matter what number I put in.

Looking at the Controller class, we might have some more tools to work with, kinda. We have the properties AnalogAim and MouseMovement. AnalogAim is a vector that seems to represent the normalized distance vector between the actor's starting aim point and the ending aim point. So basically if you're sharp aiming as far as you can directly off to the right, it's going to be (1, 0), or something very close to that. The wiki doesn't say this value is read only, but I've tried changing it and it refuses to change at all. It doesn't seem like it'll help us.

MouseMovement is a read-only vector, but does have the potential to give us an interesting bit of info. Remember how I said the amount of distance the mouse moves in a single frame is what determines the change in sharp aim? Well, this is the property that actually shows us that change in mouse position.

So my brain sees this potential solution: get the actor's controller, and store the MouseMovement vector in a local vector variable. Then, augment this local vector with your calculated "recoil" vector. Finally, pass your augmented local vector into UInputMan:SetMousePos(). The only hitch in all this is I don't know how to use SetMousePos() properly. What the hell does that second argument do?


Mon Aug 22, 2011 7:56 pm
Profile YIM
Data Realms SUPER Elite
Data Realms SUPER Elite

Joined: Thu Jun 03, 2010 10:06 pm
Posts: 3717
Location: Over there.
Reply with quote
Post Re: Changing aim angle during sharp aim
Maybe it's a Boolean, just stating if it's true or false. Have you tried setting it as 1 or 0?

I'm pretty sure you have, being that you're not an idiot.

I also think you're looking into it a bit too much, I don't think you need to use AnalogAim (which I thought was a read only, or that there was something else stopping it from being editable). MouseMovement could be really useful for "battling" the recoil and trying to push the gun's barrel back down.

I'm working on a mockup of what I think is the most ugly and simple way of doing this, but I'm not sure how it will work.


Mon Aug 22, 2011 8:16 pm
Profile
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post Re: Changing aim angle during sharp aim
AFAIK, the easiest way of doing it is setting AnalogAim every frame.

Code:
local Dist = SceneMan:ShortestDistance(self.EyePos, self.Target.Pos, false)
self:GetController().AnalogAim = Dist.Normalized


Mon Aug 22, 2011 9:26 pm
Profile
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post Re: Changing aim angle during sharp aim
It's not that complicated, just change the RotAngle of the weapon each time it shoots. And it works both with and without a mouse.


Mon Aug 22, 2011 9:29 pm
Profile
Data Realms SUPER Elite
Data Realms SUPER Elite

Joined: Thu Jun 03, 2010 10:06 pm
Posts: 3717
Location: Over there.
Reply with quote
Post Re: Changing aim angle during sharp aim
Damnit Mehman. Why'd you have to be so simple?

EDIT:

Double Damnit Mehman, I just finished my mockup, and because I'm afraid it might not work, I'm not going to even test it!


Last edited by Nonsequitorian on Mon Aug 22, 2011 9:34 pm, edited 1 time in total.



Mon Aug 22, 2011 9:33 pm
Profile
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post Re: Changing aim angle during sharp aim
Yeah, I was just about to repost your PM here. Thanks Mehman.

Abdul Alhazred wrote:
AFAIK, the easiest way of doing it is setting AnalogAim every frame.

Code:
local Dist = SceneMan:ShortestDistance(self.EyePos, self.Target.Pos, false)
self:GetController().AnalogAim = Dist.Normalized

I tried that. The value didn't seem to change at all.


Mon Aug 22, 2011 9:33 pm
Profile YIM
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post Re: Changing aim angle during sharp aim
Nonsequitorian wrote:
Damnit Mehman. Why'd you have to be so simple?


A year ago I tried the complicated method with the mouse functions(and it never worked), then today while watching a clone kill himself with his own pistol(with a change in the pistol's rotangle) I had the idea of applying the same principle to recoil.


Mon Aug 22, 2011 9:36 pm
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post Re: Changing aim angle during sharp aim
Question is how does AI handle it?

Is it more of a static aim angle and it never gets affected because its always set every frame? Or are they affected and they dont know how to handle it and the weapon just keeps climbing up?


Mon Aug 22, 2011 9:41 pm
Profile
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post Re: Changing aim angle during sharp aim
It keeps climbing up, but the ai can be modified to shoot in short controlled bursts.


Mon Aug 22, 2011 9:49 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 13 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.019s | 14 Queries | GZIP : Off ]