What's the best or recommended way to make the "is in Collision with" event only trigger once?


#1

I hoped there’d be an “object has encountered” event that would trigger only once, when the object first collides with/meets another particular object, but I don’t see one. I’d like to play a sound when my player first makes contact with something, but have the sound stop after playing once even if the player remains in contact with the object. Once the player leaves contact I’d like the sound to again play once if the player makes contact again, and so on. (I’m just trying stuff while I work on the newbie Platform game tutorial.)

If there is no such specific event, is there a simple way to suppress the event until contact is lost…or do I just have to create a variable that toggles when contact is made, but after the sound is played.

Is there also a standard way to establish that contact between objects has ceased, or will that also require some custom code?

Thanks!


#2

give a research to understand how to use the time event, if or your object is the player you will use the function to the colider with the object (x) which in this case will be the object of the collision, dps you will add one more condition to the time then you will add the time you want the sound to play and you will add another condition that is in the advanced tab that runs only once so that it is not repeated then you will add the action that will start the sound


#3

Assuming you want to do other events when the player touch the enemy, you can add a sub event to the event that checks if the player collides with the enemy.
In the sub event, add a condition called Trigger Once. Put the action to play the sound in this event.


#4

Thanks, all. I will look into your suggestions. I’d love to discover a Trigger Once event/condition!