I am trying to write a script for a hover board.
The problem I’m having is capping the speed.
The script I have does cap the speed , but then locks out the opposite force being applied.
var moveZ : float = 0.0;
var speed : float = 1.0;
var maxSpeed : float = 5.0;
var mySpeed : float = 1.0;
function FixedUpdate () {
mySpeed = rigidbody.velocity.magnitude;
moveZ = Input.GetAxis ("Vertical");
if (mySpeed < maxSpeed)
{
rigidbody.AddRelativeForce(Vector3.forward * (moveZ * speed));
}
}
Can anyone help with this simple problem?
here is the project : http://www.alucardj.net16.net/unityquestions/hoverboard%201-1a.html
here is the full script : http://www.alucardj.net16.net/unityquestions/ScriptHover1-1a.js
(note: the textures and objects are basic =] , I am just using them to write the script , and for now the rigidbody constraints are on for rotation X and Z)