Modifying mouse yaw/pitch?
Agiel
Join Date: 2006-11-14 Member: 58605Members, Constellation, NS2 Playtester, Subnautica Playtester
So, I've started playing around a bit with the code but ran into an obstacle when I wanted to implement recoil. Basically what I want to do is add some random yaw and pitch for each shot (I've already implemented free-aim which makes things a bit more complicated but I won't delve into that).
As far as I can tell the view angle is derived from input.yaw and input.pitch which are absolute values passed on from the engine. Simply changing them directly doesn't work since new values are sent each frame, so I'm guessing I'd either need a way to modify them in the engine or a way to get relative values instead. The latter would involve a lot of rewriting code but might be more flexible in the long run.
Now, either I missed something (very likely considering the current lack of documentation ;) or something like this just isn't possible yet. Anyone have any ideas/comments?
As far as I can tell the view angle is derived from input.yaw and input.pitch which are absolute values passed on from the engine. Simply changing them directly doesn't work since new values are sent each frame, so I'm guessing I'd either need a way to modify them in the engine or a way to get relative values instead. The latter would involve a lot of rewriting code but might be more flexible in the long run.
Now, either I missed something (very likely considering the current lack of documentation ;) or something like this just isn't possible yet. Anyone have any ideas/comments?
Comments
If anyone wants to try NS2 with recoil just add this to ClipWeapon:FireBullets
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->if (Client and (player == Client.GetLocalPlayer())) then
if (viewAngles.pitch > math.pi) then
Client.SetPitch(viewAngles.pitch - math.pi*2 - 0.01)
else
Client.SetPitch(viewAngles.pitch - 0.01)
end
end<!--c2--></div><!--ec2-->
0.01 is the ammount of recoil in radians. Make that higher or lower if you want. Oh, and if you're playing with invert mouse make it + instead of -. I'm subtracting math.pi*2 since angles for objects always seem to be positive while mouse input should be between -pi/2 and pi/2.
I don't know if anyone read this post or if they realized they needed the commands themselves, but thanks a lot! Now, finish up that shade so I can start playing around with the cloak shader ;)