enemy direction
deej011
Member Posts: 159
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
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.
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?
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 ?
That's impossible !
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.
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
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)
abs( distance /value)
example attached
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.
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.