- Home /
movement script
could anyone write me a quit and simple script that will make my character move forward when the w key is held down, when a or s is held down it turns the character round and move back wehn s is held down. im making an third person game and the scrips the standard assets dont do what i would like them to do. so could anyone please write me a script that will do this, thankyou.
ps im crap at scripting
pss i hope i dont waste much of your time
psss i hope i dont waste any of your time
Answer by Joshua · Feb 20, 2011 at 10:07 PM
This should do the trick.
var speed : float = 1.0; var rotateSpeed : float = 3.0;
function Update() {
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
if (controller.isGrounded) {
// We are grounded, so recalculate
// move direction directly from axes
moveDirection = Vector3(0, 0,
Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
Answer by Justin Warner · Dec 14, 2010 at 10:19 PM
...Unity comes with multiple scripts... Look for the controllers that come with it...
In the search in the editor, type controller, their's an FPS and a 3rd person one... and they have a FPS Walker script too that's more simple than the motor...
for some reason i do not have the fps walker script please can you help?
Your answer
![](https://koobas.hobune.stream/wayback/20220613091039im_/https://answers.unity.com/themes/thub/images/avi.jpg)