DMeville

Untitled

May 3rd, 2015
1,124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1. private void Update(){
  2.     //assumes class has a float "XSensitivity", CharacterController "controller", and Quaternion "characterTargetRotation"
  3.  
  4.     Vector3 fwd = this.gameObject.transform.forward * Input.GetAxis("Vertical") * speed;
  5.         Vector3 rgt = this.gameObject.transform.right* Input.GetAxis("Horizontal") * speed;
  6.         Vector3 move = (fwd + rgt);
  7.         characterTargetRotation *= Quaternion.Euler(0f, Input.GetAxis("Mouse X") * XSensitivity, 0f);
  8.         this.gameObject.transform.localRotation = characterTargetRotation;
  9.         controller.SimpleMove(move);
  10. }
Advertisement
Add Comment
Please, Sign In to add comment