View unanswered posts | View active topics It is currently Thu Mar 28, 2024 11:24 am



Reply to topic  [ 9 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
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
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
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
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   [ 9 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.314s | 18 Queries | GZIP : Off ]