Hey guys, i need help with making a script in unity that is c#, It is basically. When you are inside the collider you are able to press “e” and an animation will play. but when you arent in the collider it wont play the animation if you press “e” if someone could please help it would be really appreciated.
A quick example:
public class player{
bool allowE = false;
void update(){
//if input e && allow e
//insert code
}
}
void OnTriggerEnter(Collider other) {
if (other.CompareTag("Player")) {
//get player
//player.enableE ...
}
}
void OnTriggerExit(Collider other) {
if (other.CompareTag("Player")) {
//get player
//player.disableE ...
}
}