Hi all. I have created an accelerated movement on my player object in game using the following code:
var rotVert:float = 1.0;
var horVelocity:float = 1.0;
var verVelocity:float = 1.0;
function Update() {
horVelocity += 5 * Time.deltaTime; // increases horVelocity by 5 per second
horMovement = Input.GetAxis("Horizontal") * Time.deltaTime * horVelocity; // gets axis for horizontal movement and applies velocity per second.
transform.Translate(0, horMovement, 0); // moves by the value defined by the calculations in horMovement along the X axis.
verVelocity += 1 * Time.deltaTime;
verVelocity -= 10;
verMovement = Input.GetAxis("Vertical");
if (verMovement) {
transform.Rotate(Vector3(0, rotVert, 0).right * verMovement * verVelocity);
}
}
I was wondering if it is possible to set a maximum value to horVelocity and verVelocity. I am familiar with Java but JavaScript is relatively new to me. Ordinarily I would use the < > symbols but i cannot find any reference to their use in this context. Can someone show me how to create a maximum value please?
Thanks