Make enemy follow hero only in 90 degrees (straight lines) ?

POMPOM Member Posts: 2,599
edited November -1 in Working with GS (Mac)
Hey ,
Im trying to make my enemy to follow my hero but restrict its movement only to up/down/left/right
meaning without diagonals movements ,
i managed to do this but its kinda choppy in its current status ,
Is there any template for this already ?
Or do you have an idea of how to make it?

Roy.

Comments

  • DimensionGamesDimensionGames PRO Posts: 993
    WOops my answer was helping with you for just moving character not following sorry :/
  • POMPOM Member Posts: 2,599
    Ill give it a try but ,
    The thing is that the hero is constantly moving so the enemy will always try to reach for its Y... :/

    Roy
  • dmilinovichiiidmilinovichiii Member Posts: 620
    tshirtbooth said:
    hmmm,

    What if you told it to move to the players Y first. then once the Y matches it moves to the x. And if the Y changes it goes back to moving to the Y and then to the x again.

    just thinking out loud

    cheers

    Maybe if you edited that and said that when the enemy's Y is within 50 pixels of the character's Y, the enemy tries to match the X of the character. You can edit this farther until it narrows down on the character.
  • POMPOM Member Posts: 2,599
    Mr.Rinoy said:
    Maybe if you edited that and said that when the enemy's Y is within 50 pixels of the character's Y, the enemy tries to match the X of the character. You can edit this farther until it narrows down on the character.

    Yeah that's exactly what I did in the first place, but I'm having issues with this, see let's say there are 5 enemies in the scene, and they all follow the hero with this method, the result make them overlap perfectly so that 5 enemies look like 1..
    That's why I'm asking to see if there is a different method ..
    Man those "simple" things are hard...
    Roy.
  • MotherHooseMotherHoose Member Posts: 2,456
    does putting collide on the enemies help???

    Rule when Actor receives an event overlaps or collides with actor type enemy
    changeAttibute self.Position.X to self.Position.X-20
    changeAttibute self.Position.Y to self.Position.Y-20

    MH
  • POMPOM Member Posts: 2,599
    MotherHoose said:
    does putting collide on the enemies help???

    Rule when Actor receives an event overlaps or collides with actor type enemy
    changeAttibute self.Position.X to self.Position.X-20
    changeAttibute self.Position.Y to self.Position.Y-20

    MH

    Thanks for trying to help MH ,
    But i don't see what you are trying to do , if 2 enemies with the above rule will collide , both of them will go 20 pixels down and left , am i missing something?

    Roy.
  • MotherHooseMotherHoose Member Posts: 2,456
    well...the 20 and the down and left were just used as examples...I don't know the size of your enemy...or the direction you want to send them...

    what will happen is they will veer away from each other...
    (probably at an angle unless you timer-delay (after 0.01 seconds) the Y (or X) changeAttribute)

    the change X or Y on collision will keep them from looking like one...

    MH
Sign In or Register to comment.