0 Favourites

# Object outside layout bug [SOLVED]

This forum is currently in read-only mode.
• 4 posts
• Hi everyone! In my game I use platform behavior for AI. Here is a part of enemy movement event sheet.

Everything works fine only when enemy goes outside from the right side of a screen. But when he leaves layout from the left he doesn't turn back. Any ideas why?

• Because the last event overrides the preceding event.

When the enemy leaves the layout to left, what do you suppose happens?

1. The event 3 is true, as it is outside layout and the angle is 180. Set the angle to 0.

2. Next, check the last event, keeping in mind that we now have angle at 0. Still outside layout? Yup. Angle equal to 0? Yup. Set angle to 180.

So what do we have here? An enemy that keeps turning back and forth just outside the layout.

You accidentally logic. ;)

Tip: you can condense those events this way-

+ enemy has wall to left

+ OR

+ enemy has wall to right

+ OR

+ enemy is outside layout

enemy: set angle to enemy.Angle + 180 (180 becomes 0 and 0 becomes 180 )

enemy: set horizontal speed to enemy.HorizontalSpeed * -1 (260 becomes -260, -260 becomes 260)

Just set the speed at start of layout or something and there you have it, everything you want in one event. :)

• Because the last event overrides the preceding event.

When the enemy leaves the layout to left, what do you suppose happens?

1. The event 3 is true, as it is outside layout and the angle is 180. Set the angle to 0.

2. Next, check the last event, keeping in mind that we now have angle at 0. Still outside layout? Yup. Angle equal to 0? Yup. Set angle to 180.

So what do we have here? An enemy that keeps turning back and forth just outside the layout.

You accidentally logic. ;)

Tip: you can condense those events this way-

+ enemy has wall to left

+ OR

+ enemy has wall to right

+ OR

+ enemy is outside layout

> enemy: set angle to enemy.Angle + 180 (180 becomes 0 and 0 becomes 180 )

> enemy: set horizontal speed to enemy.HorizontalSpeed * -1 (260 becomes -260, -260 becomes 260)

Just set the speed at start of layout or something and there you have it, everything you want in one event. :)

Thanks that worked!