Hello all, joined the forum to just ask this question, although I'm sure ill have more! This is the code I am using to get gun sway while my character is running. My issue, is that its starts swaying before I press "w" and just continues and continues. The goal is to press "w" and then the animation start, and stop when "w" is not pressed. function Update() { if(Input.GetKeyDown("w")) { animation.Play("walkingbehavior", PlayMode.StopAll); } }
If your making an FPS you might want to check out these assets. They contain examples of code similar to what your doing, and you can look at the code to see how they do it. http://u3d.as/content/dastardly-banana-productions-llc/fps-constructor/2yA http://www.fpscontrol.com/ Edit: The fps constructor is old if you want to try it you have to change a line of code in the first one that comes up as error. I think it's AimMode.js Code (JavaScript): // Instead of: 9.EditorGUIUtility.LookLikeInspector(); 10.// Use: 11.EditorGUIUtility.labelWidth = 0; 12.EditorGUIUtility.fieldWidth = 0; You'll also have to set up a lot of inputs!