Ennemy changes direction after a collision
silvios
Member Posts: 29
Hello,
I am doing a project, and I have an issue.
I want an actor to change its direction after collinding with a wall. The ennely is moving alone, with a behaviour move.
When it collides the wall, I want it to move in the opposite direction. So I did like that :
When self.position.X < 2000
Actor moves right
And :
When self.position.X > 2450
Actor moves left
But after being < 2000, my actor does not go to right, just the animation works.
Can you help me please ?
I am doing a project, and I have an issue.
I want an actor to change its direction after collinding with a wall. The ennely is moving alone, with a behaviour move.
When it collides the wall, I want it to move in the opposite direction. So I did like that :
When self.position.X < 2000
Actor moves right
And :
When self.position.X > 2450
Actor moves left
But after being < 2000, my actor does not go to right, just the animation works.
Can you help me please ?
Comments
http://hpics.li/cb4fd69
Like in this video (1:21), having an ennemy that walks alone and change direction after colliding with a wall :
That is working as it should, your rule . . . .
When self.position.X < 2000 / Actor moves right
. . . says when the actor's position is less than 2,000 then the actor should move right, so when it eventually gets to 2,000 its value is no longer less than 2,000 so will no longer be subject to the rule that tells it to move right . . . . so it stops.
Socks : Indeed, it is logical. So how I should do that ?
Mystic : yes I want it to move before he collides with the wall. How can I do with the magnitude function ? I do not know that thing
Rule:
When x position is equal to or greater than 2450:
Interpolate x position to 2000
Rule:
When x position is equal to or smaller than 2000:
Interpolate x position to 2450
example: https://www.mediafire.com/?4xrckmkrl8boq34