Breaks after 15 sec

In my game, i have a very simple enemy ai that just bounces off of what it runs into and heads the other way.


events

heres a video of what happens

the toggles are hidden at the beginning but ive looked at it with them visible, after 15 seconds (that green box fills) they just ignore the toggle and don’t change direction

Solution-

My “Solution” was to use a timer to effectively “double check” if they are still in collision after half a second.

I don’t understand what the problem is, could you explain it better?

It’s hard to tell from what you’ve provided, mainly because we wan’t see where the toggle object is. However, it sounds suspiciously like there’s an enemy that’s in contact with the toggle object when a second one collides with it.

Because the first enemy is still colliding with it, the event won’t trigger and subsequently the second enemy won’t turn. And so there will always be an enemy touching the toggle object, and the event will never get fired again.

Note, the trigger once applies to the object type, not each instance of the object.

Here’s a link to a very similar case, with a solution.

Sorry about the lack of detail. Theres enemy spawners on the ceiling that spawn enemies every 2 seconds. The toggles are placed only in places I want them to turn around

(eg. of the toggles)

You’re correct about why its breaking, I came to that conclusion a little while ago and I tried the solution from that other post but it didn’t work still.

I’ve been pretty stumped about how to fix it without figuring out a completely different method for the enemy to move and have that same effect.

I came up with a solution that seems to be working.

it just checks again if theyre still in collision and changes it if they still are after half a second

Hmmm, the timer solution still has the potential for problems though. For example, if the enemy is in collision with the toggle object for 2 successive frames, it’ll continuously toggle the state.

The work-around from the link does work, and it’s a pretty problem-proof solution. If you’re willing to give it another shot, we can always help if it doesn’t appear to work for you.

1 Like

When I get working on the game again I’ll give it another try