I am working on a horror game and i have a section where i have a cube as a trigger, when the player enters the trigger a dead body appears and falls down using Instantiate, my only problem is everytime you leave the trigger and come back in, Instantiate is triggered again and another dead body appears and falls down ontop of the first one. How do i make it so Instantiate is only activated that first time and after even if the player walks through the trigger again Instantiate isnt activated again?
Use a single boolean to control dead body fall
bool bodyFellOnce = false;
void OnTriggerEnter()
{
if( !bodyFellOnce )
{
// your body instanciation
bodyFellOnce = true;
}
}