Hi guys, in this script if you press Q the object goes up, instead if you press E, it goes down. but it should have limits for both (max hight and minimum down position). I sow that I have to use Mathf.Clamp to set the limits, but in the unity API ther’s an example with “transform.position”, I don’t have It in my script. Where Can I put The Mathf.Clamp limits in my script?
Thank you and happy holidays to everyone
#pragma strict
var GoUp = 1.0;
var GoDown = 5.0;
function FixedUpdate() {
if (Input.GetKey(KeyCode.Q)) {
GetComponent.<Rigidbody>().AddForce(transform.up * GoUp);
}
else if (Input.GetKey(KeyCode.E)) {
GetComponent.<Rigidbody>().AddForce(-transform.up * GoDown);
}
else if (Input.GetKey(KeyCode.W)) {
GetComponent.<Rigidbody>().velocity = GetComponent.<Rigidbody>().velocity * 0.9;
}
}