I am trying to make like an interaction zone so when you’re with this object range press e to do this action. I read someways on how to do it but I am unsure how to implement it correctly.
For example:
Press E to get in the car.
I am trying to make like an interaction zone so when you’re with this object range press e to do this action. I read someways on how to do it but I am unsure how to implement it correctly.
For example:
Press E to get in the car.
void OnTriggerStay(Collision collision) {
if(collision.gameObject.tag = “car” && Input.GetKey (KeyCode.E)) {
//Do your stuff here
}
}
UnityScript:
function OnTriggerStay(collision : Collision) {
if(collision.gameObject.tag = "car" && Input.GetKey(KeyCode.E)) {
//Do your stuff here
}
}
Of course, you have to set up the tags.