[SOLVED] Double-point Error

Hi! I recently solved a problem through this forum and so I’m back with a new one.
(disclaimer: I refer to the event of my character colliding with the object as “eating”)

As mentioned in my previous question, I’m making a flappy bird remake. I want the character to collect “apples” as a variable for a score, with a sound effect.
I spawn the pipes (“walls”) randomly through an external layout along with the apple in the middle like this:

However, when I try the game out, the apple sometimes is eaten twice (points go up by 2, sound effect also plays twice, but the apple just disappears once the first time).
I’ve tried to use a scene timer to increase the scores instead of a colliding event but it’s a little off the timing with the apple-eating.

Also, I made the character rotate on every jump using the FaceForward extension, so it might be because the character gets in touch with the apple twice within the “trigger once”, but I’m not sure how to fix it.

Please help me - I’m not sure if it’s the character colliding with the apple twice or if it’s just a code error.
This is my code:

A trigger once is more like a trigger once while true It stops the action from triggering more than once while the conditions are true. If the player is able to collide with the apple more than once then it will trigger multiple times. The trigger once is removed as soon as the conditions are false. It’s then ready to trigger the actions again.

A fix would be to add another condition like Apple is visible Then it would ignore hidden apples. Normally, the object would be deleted and this wouldn’t be an issue. I’m assuming you’re doing it this way for replayability.

Try this:
When the character is in collision with apple…then…destroy the apple (instead of hiding the apple)

With this you will get it to run only once.

Tried the Apple is visible condition and it worked great!!
Destroying the apple also works too.
Thank you so much!

1 Like