- Home /
Having trouble moving character backwards...
I already have my character moving forward and rotating, but having trouble moving backwards... Here is my code for moving forward: function moveForward(){
//Move forward
forward = trans.forward * Time.deltaTime * moveSpeed;
//move character on key pressed
if(Mathf.Abs(Input.GetAxis("ForwardBack")) > 0){
transform.Translate(forward);
}
}
Any suggestions? I've followed burgZerg Arcade's tutorial on Youtube (video 93.) on this, but it doesn't work for me...
Comment
Answer by superventure · Nov 05, 2011 at 08:49 PM
`enter code here`in Update
var controller : CharacterController = GetComponent(CharacterController);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
//Move the controller
controller.Move(moveDirection * Time.deltaTime);
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
}
@script RequireComponent(CharacterController)
Your answer
Follow this Question
Related Questions
Simple Character Movement 1 Answer
Moving character....northwest...? 1 Answer
how do I create a character 2 Answers
How can my character stop moving immediately after it gets hit by enemy? 1 Answer
Moving Cube Forward 3 Answers