Advertisement
Munchy2007

FixedUpdateForces

Mar 17th, 2016
21,252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1.     // Handle Forward and Reverse forces
  2.     if (Mathf.Abs(thrust) > 0)
  3.       body.AddForce(transform.forward * thrust);
  4.  
  5.     // Handle Turn forces
  6.     if (turnValue > 0)
  7.     {
  8.       body.AddRelativeTorque(Vector3.up * turnValue * turnStrength);
  9.     } else if (turnValue < 0)
  10.     {
  11.       body.AddRelativeTorque(Vector3.up * turnValue * turnStrength);
  12.     }
  13.  
  14.     // Limit max velocity
  15.     if(body.velocity.sqrMagnitude > (body.velocity.normalized * maxVelocity).sqrMagnitude)
  16.     {
  17.         body.velocity = body.velocity.normalized * maxVelocity;
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement