In this project your given the code for the tick function. However this is a rather dangerous way to use the tick function. If the PressurePlate is left empty or the IsOverlappingActor then this will crash Unreal.
Code in Question:
if (PressurePlate->IsOverlappingActor(ActorThatOpens)) { OpenDoor(); }
Instead you should do something like(Atleast):
if (PressurePlate != nullptr) //If PressurePlate is not empty { if (PressurePlate->IsOverlappingActor(ActorThatOpens)) /* Then Check if PressurePlate is Overlapping ActorThatOpens */ { OpenDoor(); //Open Door } } }
You could also do another check to see if there is someone to open the door.
This should stop any errors related to PressurePlate from occurring. So why would you want to use my code over the teachers code: Well if you ever don’t wnat to have a PressurePlate Defined in the Code. You need to use my code instead, AKA you don’t want to assign a PressurePlate to a door you don’t want to open but for whatever reason you want to keep the doorOpen compouent. Or you want to have several diffrent ways to open a door such as a button, timer, etc, you probably don’t want to also define a trigger volume for every door.
Also its a good habbit to get into.