- Home /
3rd person shooter movement issues
I have an issue with my character jumping intermittently on my map. I perceive it occuring randomly and the odd thing is I am providing no control in the y-axis! Sometimes it will not occur (for an entire gaming session), which is frustrating the debugging process. When it occurs it only appears to happen with the Horizontal key input for forward/backward movement. There does not seem to be an issue with rotating the character.
I am using he following script to move my character around the map. I've been troubleshooting the issue for a bit and have tried a few things (thus all the remaining comments in the code). I initially tried this in the Update() and FixedUpdate() functions but saw a few posts recommending that the movement be performed in the FixedUpdate. Additionally, I have set the input settings for Horizontal and Vertical to have an extreme gravity and sensitivity, but still have the issue. I've also tried adjusting the size of the character controller component around my character but this does not help and actually has caused some issues with colliding.
Has anyone encountered this behaviour in their games? Would anyone mind dropping this bit of code in their 3rd person game to see if they get the same problem? I've added gui output of the local and word transformDirections of the character, and have verified that neither have values in the y-axis as my character proceeds to launch in the air. I've even set y values to zero in the below script to ensure the transform directions are not inadvertanly going to something other than zero in the y-axis (in the event they are being initialized to something other than zero).
function Update () {
var controller : CharacterController = GetComponent(CharacterController); // rotate left/right around Y-axis transform.Rotate(0,Input.GetAxis("Horizontal") rotateSpeed Time.deltaTime,0);
// Move forward/backward var forward = transform.TransformDirection (Vector3.forward); var curSpeed = speed Input.GetAxis("Vertical"); //SimpleMove is in m/s rather than frames/s so no Time.deltaTime req'd controller.SimpleMove(forward curSpeed);
}
Note: This is a repost, cleaned up, but mainly due to the fact my previous post was for some reason not linked to my registered account, I apologize for not being able to edit the original post...
Thank you in advance for taking the time to review this wordy post.
Answer by jrbailey1977 · Jan 09, 2011 at 09:19 PM
This link helped me solve this problem.
http://answers.unity3d.com/questions/4881/character-controller-randomly-flies-up
It wasn't a script issue. My character model that the controller was attached to, had child game objects with colliders. Removing the child object colliders corrected the random jumping of my character.
On another note, I would like to know why this was voted down. I am new to the board, so if I've breached some sort of etiquette, please let me know so I can correct.
Thanks to those that viewed.