Character Control Script

By Jack Eaves
var speed = 10.0;
var rotatespeed = 100.0;




function Update () {

var forward = Input.GetAxis ("Vertical")*speed; 
var strafe = Input.GetAxis ("Horizontal")*speed; 
var rotate = Input.GetAxis ("Mouse X")*rotatespeed;

forward*= Time.deltaTime;
strafe*= Time.deltaTime;
rotate*= Time.deltaTime;

transform.Translate (strafe,0,forward);
transform.Rotate (0,rotate,0);

}

TIPS:


  • Everything should be inside the 'Function Update () { [Insert here }' In order to work, however the Variables will be outside of this Function Update (Setting speed etc)
  • 'Time.deltaTime; ' = means that the speed is set to Speed per Second instead of Speed for Frame Rate.
  • All of the appropriate upper and lower case letters should be exact in order to work. (for example 'Time.deltaTime;' should be exact.
  • Go to Edit > Project Settings > Input to show the list of needed inputs such as 'Vertical' or 'Horizontal' or 'Mouse X'
 

0 comments so far.

Something to say?