BGE's FSM On Enter State?

Hello, I’m making a Mario game and he has a great variety of movements for which I’m creating functions using python modules, I will give an example of my problem.

Basically I need to play a sound only once when I enter the state hitting wall, the problem is that the sound is looping while the state is active, I know I can play it when leaving the previous state, but for design decisions I need to play it there.

So, my question, is there any functionality that allows me to execute code only once when entering a state? or is there any workaround?

Set a property = True and check it at the begining of the script

In the first execution of the script set it to false.

A single always sensor (perhaps with with TAP should suffice)

Sent from my Nexus 5 using Tapatalk

It makes sense, I’ve been using properties for similar stuff, I guess that’s the most logical approach.

I’ll try that, thanks agoose.