This script is used to allow the player to interact with objects via triggers and with an interact key.
Update():
In the update function, there is currently a check for if the "E" key is down which will set the isEDown bool accordingly.
OnTriggerEnter(Collider other):
This does the basic OnTriggerEnter stuff and then has an if statement to check if the object has the "Intractable" tag. If it does, it will get the IInteraction interface from that gameobject and call Interact() from that gameobject.
OnTriggerStay(Collider other):
This does the same thing as OnTriggerEnter however, since we require an input, we need to stay down a little longer. This is used for pushing an object. If the object has the tag "Pushable" and the isEDown bool is true, it will get the PushableBlock component from that script and call Push().
Comments
Post a Comment