Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Handle Forward and Reverse forces
- if (Mathf.Abs(thrust) > 0)
- body.AddForce(transform.forward * thrust);
- // Handle Turn forces
- if (turnValue > 0)
- {
- body.AddRelativeTorque(Vector3.up * turnValue * turnStrength);
- } else if (turnValue < 0)
- {
- body.AddRelativeTorque(Vector3.up * turnValue * turnStrength);
- }
- // Limit max velocity
- if(body.velocity.sqrMagnitude > (body.velocity.normalized * maxVelocity).sqrMagnitude)
- {
- body.velocity = body.velocity.normalized * maxVelocity;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement