I’m trying to figure out how to change mathf.clamp values once a player hits a trigger.
but I have no idea how, my attempt looked something like this:
var shouldConstraint : boolean = true;
var bullet : Rigidbody;
function Update () {
if (shouldConstraint){
transform.position.x = Mathf.Clamp(transform.position.x, -3.9, 3.9);
transform.position.z = Mathf.Clamp(transform.position.z, -18.8,19);
}
}
function OnTriggerEnter(otherObject: Collider){
if(otherObject.gameObject.tag == "playercollision"){
transform.position.x = Mathf.Clamp(transform.position.x, -3.9, 3.9);
transform.position.z = Mathf.Clamp(transform.position.z, 13.7,19);
shouldMove = false;
}
but it doesn’t quite work, but it’s the only idea I can think of, any ideas?