Advertisement
Munchy2007

FixedUpdate

Feb 12th, 2016
4,477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. void FixedUpdate()
  2.     {
  3.         if(isLocalPlayer == false) return // Don't try to move the player
  4.                                           // if this isn't running on the local player object
  5.            
  6.         // Remove unwanted forces resulting from collisions
  7.         body.velocity = Vector3.zero;
  8.         body.angularVelocity = Vector3.zero;
  9.  
  10.         // Handle rotation
  11.         var rot = body.rotation.eulerAngles;
  12.         rot.y += hInput * rotationSpeed * Time.deltaTime;
  13.         body.MoveRotation(Quaternion.Euler(rot));
  14.  
  15.         // Handle forward movement
  16.         body.MovePosition(body.position + vInput * trans.forward * 5f * Time.deltaTime);
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement