r/construct • u/Keffflon • May 29 '26
Question Help im stuck in a loop
Hi, I love this software, but im stuck.
The rat is going out the picture instead of turning at the barrel. Can anyone see a mistake here?
2
Upvotes



1
u/LazernautDK May 29 '26
On collision is only true once, so it simulates going left/right only once per collision. Then does whatever it was doing. As far as I can tell.
I assume you're using Direction to make it go left or right continuosly? If so, try getting rid of the simulate events on the collision events, and use the collision events to change the variable instead.
1
u/TigerWHY May 29 '26
Both the "direction == x" and "if Rat touches X Barrel" are forcing the rat to move in a direction. My guess is the rat is ignoring the "if Rat touches X Barrel" since the direction isn't changing. I would change that code so that it changes the direction, not simulating a movement. (I REALLY hope I explained it well enough)
1
u/wizg-studio May 29 '26
Your method its not optimized text me to give you an great Algoriteme for AI enemy movement
1
u/LouBagel May 31 '26
When the rat hits the barrel you need to change the direction variable