- Home /
3rd person character movement problems
I have an issue with my character jumping intermittently on my map. It 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. I am almost ready to model a rickety jetpack on my character and call this a feature (j/k). 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() function 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?
function FixedUpdate () {
var controller : CharacterController = GetComponent(CharacterController); //var playerMoveDirection = Input.GetAxis("Vertical") ; //var playerRotateDirection = Input.GetAxis("Horizontal") ;
// rotate left/right around Y-axis transform.Rotate(0,Input.GetAxis("Horizontal") rotateSpeed Time.deltaTime,0); //transform.Rotate(0,playerRotateDirection * 90,0);
// Move forward/backward var forward = transform.TransformDirection (Vector3.forward); //var curSpeed = speed playerMoveDirection Time.deltaTime; 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);
// keep track of where the player is on the grid playerPositionCol = Mathf.Round(transform.position.z); playerPositionRow = Mathf.Round(transform.position.x);
}
Answer by jrbailey1977 · Jan 09, 2011 at 11:02 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.
Your answer
Follow this Question
Related Questions
CharacterController.SimpleMove() doesn't exist? 0 Answers
C# Jumping Issue 1 Answer
Character Controller Jittering 0 Answers
Character with controller flies off map. 2 Answers
How to fix a infinity jump? 1 Answer