Object outside layout bug [SOLVED]

This forum is currently in read-only mode.
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Except you shouldn't use or - it's buggy and can cause crashes.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)