I have a script which will damage the player if he comes into contact with an enemy. Its works, but the problem is if the player doesnt move instantly all his health will be removed as there is no delay between contact hits, and I dont know how I can add a delay?
OnTriggerEnter should happen only once per collision. However, you could have the code in the function run only if a bool is true, and then set that bool after some time using an IEnumerator coroutine.
To me that means you have something set up wrong. How are you moving your objects?
Making OnTriggerEnter only do something once is just a bandaid to your real problem. It should only run once per overlap by design, so fix that and your problem is solved.
You can still add a delay on top of that if you want, like this:
That’s brilliant pal cheers, its working properly now.
I have no idea why it wouldn’t work as it was though. My objects move either by a waypoint system or a simple mover script. I dont think I have anything super fancy running.