MoveTo behavior stuttering for some odd reason

1 favourites
  • 6 posts
  • Hi all,

    I am trying to create an enemy type that when it reaches the range it can attack a player from, it dashes into the player.

    I tried to do this with LoS instead of the distance expression I am using below but I get the same exact stutter result.

    First, here is my "code":

    i.imgur.com/S8EODEd.png

    This is the result:

    i.imgur.com/GNm2oNG.gif

    I don't know why the enemy (purple) moves in "steps" towards the player. I tried to chang the speed (currently it is set to 800 as you can see from the text box) while that helped, that "steps" feeling is there but it slightly less noticeable.

    On a side note, the enemy has a Custom Movement behavior enabled on it but I only use it to stop enemy sprites from overlapping.

    Any ideas what is going on here and what I can do to fix this?

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You are using Wait action inside of "Every 0.2s" event. If the wait time is longer than 0.2s, then the whole thing will quickly become a mess. The event will continue running and creating more and more delayed threads. Which probably explains why the movement is broken.

    Also, that code won't work with multiple enemies, because distance() expression will only check the first enemy instance.

    I suggest you use a state machine approach with Timer behavior instead of "waits" and "every X seconds".

    Use LOS behavior instead of distance, or add "For each enemy" loop if there are more than one enemy instance.

  • I see what do you mean. Thank you very much, I'll recode it using state machines with LOS :)

  • LOS is great for distance checks. 👍 Only recently started to use it in my new game for enemy AI.

    But I have a problem with overlapping enemies. I added some code to slow one of them when overlapping to prevent it. I tried making them solid but that didn't work well.

    You can prevent it with custom movement behavior?

  • Bl4ckSh33p Check out the pathfinding examples. Recent changes in the Pathfinding behavior allow to spread instances out and prevent them from overlapping.

  • Thanks, I tried pathfinding with the new groups but it didn't work. there are basically no obstacles on my space game and they all used the same path with and without the group mode. I wrote my own code on overlap to pick the 1st overlapping instance and half it's speed (move to).

    But I'll take a look at custom movement next.

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