How do I move an object or enemy in a set pattern?

1 favourites
  • 5 posts
From the Asset Store
10 Beautiful Pokemon-like Building Pixel Art Sprite Sets
  • I am making a game that uses Tile Movement, and I am trying to figure out how to move some of my enemies.

    Basically, I want to move an enemy in a set pattern, with each movement taking place at a set interval.

    For example, I have a spider. I want the spider to move one tile to the right and then wait a second. Then another tile right, and wait a second. Then one tile down and wait a second. So on and so forth, until it completes a full circle, basically.

    If I use Simulate Movement every second, it acts as if the button (right, down, left, up, or right) is being held down rather than just pushed a single time to move a single tile.

    For some reason, I can't seem to get the enemy to move the way I want. Any suggestions?

  • Hi

    Use Timers for the "wait" so every Time they trigger move 1 tile to the Angle that is the Next move"

    Probably you need instances Variable too:

    Var "Moves Count" >>> (Type = Number) = 0

    On Timer Triggered

    Sub Event: "Moves Count" < 2: >>>>> Actions Move 1 Tile Right & Add 1 to"Moves Count" & start the Timer again

    Else: Move 1 Tile Down

  • I tried using timers in a variety of ways and it hasn't been working. The weird issue I'm having is that no matter how I try to move the enemy, it just flies off screen.

    I did Every 1.0 Seconds, move 32 pixels at angle 0. When I press play, after 1 second the enemy flies off screen instead of only moving 32 pixels.

    I don't know if it's constantly trying to move the enemy 32 pixels every tick or not. I came up with a solution that works by adding "On Start of Layout" to the code. Then every works great, but I can't get the code to run constantly. It will run once and then stop. Using any sort of Repeat or While action will cause the game to either not load, or make the enemy fly off screen again.

  • Hi SnowyCroww

    Not sure what could be the problem in your end as I cannot see your project but I made a demo to move the spider in an "L" shape move.

    I don't know what set of rules you have in your Game for the Spider so I made my simple:

    -You Mode until you complete the "L" shape sequence then you reset the move again and again in a loop but with a pause between moves 0.5 or 2 when it resets

    or

    -If he hit any solid he waits 2 seconds and resets the "L" shape move by finding an alternative Path

    Every time he completes the "L" Move he finds a new Angle to start the new "L" Move

    Also, he chooses Angle at random to complete the "L" shape Move

    Example

    If he is moving horizontally at the "Right"

    He will move two times "Right" then it will pick random (Up or Down)

    And the same when he moves vertically

    Capx:

    https://www.dropbox.com/s/k2hg25kv1u0wr1y/spider%20move.c3p?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This was a huge help, I think I've got things figured out now. Thanks for the help.

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