How do i make my gun sway like in call of duty 4?
3 Answers
3Use an animation.
Or use gradual motion using the MAthf.lerp function to make it slowly sway from side to side.
But an animation is MUCH easier.
@FutchProductionsSyndicate one more question how do i play the animation while i look to the sides on the mouse?
– anon54437435@Keith18127389 Sorry, i'm not quite sure how to do that. what you could do is a combination of animations and a Lerp.... Have it loop an idle animation of the gun bobbing and swaying, and when you look to the sides, use the Mathf.lerp function to gradually move the gun and rotate it slightly. I'm not completely sure how that would work with the animation, but I think it should work fine.
– anon53045764"duty 4 " I haven’t played it yet.Can you describe your question in another way?
NOTE TO MYSELF: I should use a comment next time. Not a answer! – OrangeLightning ![]()
Please do things like this as a comment, and he means in the game, "Call of Duty 4" how the gun sways side to side and bobs up and down to make it look like you are walking.
– anon53045764Sorry , by "variable index" I mean the id number in the animator "parameters" tab, which is the same thing you get by doing Animator.StringToHash. If you already know the id number form there, you could simply use it like: First parameter name "speedPercent", myAnimator.GetFloat(0); is the same as myAnimator.GetFloat("speedPercent");
make it rotate the same way you make the camera rotate. it is simple. one problem you may find is that it begins to move off of the screen. this is simple to fix just use the Mathf.Clamp() function that is how i did it
you should write the name without the brackets "[" "]"
– Destolos