Prevent Enemies from Moving off of Ledge [SOLVED}

This forum is currently in read-only mode.
From the Asset Store
Pixel Enemies for SHMUP consists of 45 enemy ship sprites to be used in your game.

    In this small example I'm working on, the player character is chased by robots.

    To achieve this, I have the robots move like so:

    RoboX >= PlayerX

    Set Speed to 0 - Speed.Value

    RoboX <= PlayerX

    Set Speed to Speed.Value

    I want to keep them on specific platforms. So I place little boxes called Borders on the edges.

    RoboX >= Border.Left

    Set RoboX to Border.Left - 4

    RoboX <= Border.Right

    Set RoboX to Border.Right + 4

    But that does not work.

    Now, I gave the Robos platform behavior for walking around - I've tried Custom Movement but it seems to run in to the same problem.

    I suspect that the issue might lie in what the Robos detect is Border.Left and Border.Right, because it seems that toggling one or the other yields the same results as having both conditions on. Perhaps something with the set Horizontal Speed to Speed.Value? The possibilities are endless :p

    There is the possibility that even in the space of 4 events, I've complicated this more than necessary. Basically, I just want the game's enemies to stay on their own platforms, hanging out on the edge until the player moves past them, changing their direction. They're always following the player.

  • I made a fix for you:

    Using the abs() built in function I cut the number of events in half.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • As usual, I would not have thought to use the abs() system expression - really the Achilles heel of my Construct knowledge.

    Thanks for the help! I didn't think you could shrink down 4 events any further, but I guess that shows what I know! : p

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