Code (csharp): var maxVel : float = 1.0; function FixedUpdate() { if (rigidbody.velocity.magnitude > maxVel) { rgidbody.velocity = rigidbody.velocity.normalized * maxVel; } }
It makes the variable of type float. In other words, floating point compared to integer. Note however that there's no difference between using "var maxVel : float = 1.0;" and "var maxVel = 1.0;" because using 1.0 automatically makes maxVel of type float. On the other hand, using "var maxVel : float = 1"; makes maxVel a float, whereas "var maxVel = 1;" makes it an integer, since a number without a decimal is interpreted as an integer unless you say otherwise. I'm normally in the habit of explicitly defining types all the time, just in case I use "1" instead of "1.0" (or whatever), and I want it to be a float. Saves some potential aggravation, at the expense of some possibly unneccesary extra typing. --Eric