enemy direction

Im having another go at making an RPG (good luck haha) im having trouble when im within a certain distance from a enemy i wont it to walk towards me but i want it to walk along the x and than y axis or vice versa not diagonally, any suggestions??

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2015

    In the Enemy actor.

    Detect if the hero is within range (using magnitude).

    Interpolate (or whatever you are using to move) . . to hero X

    When the Enemy's X position = hero's X position - then Interpolate the Enemy's Y position to hero's Y.

  • deej011deej011 Member Posts: 159

    thanks for the help is there any way to interpolate over speed instead of time? and for some reason when the enemy reaches hero x it moves towards the y but on a diagonal?

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2015

    @deej011 said:
    thanks for the help is there any way to interpolate over speed instead of time?

    Just use some simple maths for the duration, for instance . . . a value / a divisor . . . so 100/10 . . . if you want the speed to be faster then increase the 10 . . . but I'm not sure why you'd want to do this as all you are doing is swapping the need to decrease a number with the need to increase a number ?

    @deej011 said:
    and for some reason when the enemy reaches hero x it moves towards the y but on a diagonal?

    That's impossible ! :smile:

    If you have reached the X position - the only direction you can move towards the hero's Y is vertically ?

    Can you take a screenshot of your rules.

  • deej011deej011 Member Posts: 159


    with the duration i want the enemy to move towards me at one constant speed but with time it will either move towards me really slowly or really fast depending how far away from it i am

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2015

    @deej011 said:

    Mmmmmm . . . . that should so exactly what it appears to be doing, when the target is within range, move to the target's X . . then when aligned with the target's X move to the target's Y . . . ?

    Works for me when I try it - perhaps you have got some other stuff going on in the project that is effecting this actor ? (for example I don't want what self.move is or how self.distance is calculated . . . etc etc)

    with the duration i want the enemy to move towards me at one constant speed but with time it will either move towards me really slowly or really fast depending how far away from it i am

    abs( distance /value)

    example attached

  • deej011deej011 Member Posts: 159

    i figured out the X and Y thanks for that, with the abs what if the distance (self.PositionX-game.PositionX) is constantly different from the player moving?

  • SocksSocks London, UK.Member Posts: 12,822

    @deej011 said:
    i figured out the X and Y thanks for that, with the abs what if the distance (self.PositionX-game.PositionX) is constantly different from the player moving?

    I don't know what 'constantly different from the player moving' means.

  • deej011deej011 Member Posts: 159

    sorry the distance value (self.PositionX-game.PositionX) is constantly changing as the player is moving around the map so the distance/the value is never the same unless the player is standing still.

Sign In or Register to comment.