Moving, stopping then moving again

My monster is supposed to advance till it hits an actor. Then it stops and displays the kill animation then starts moving again. I can't get this to work for some reason.
I've tried both move and accelerate speed 100
then a rule if collide with actor
move speed 0
animate
move speed 100
This doesnt work. He just keeps moving and killing and never stops. What am I doing wrong? Thanks for any help.
I've tried both move and accelerate speed 100
then a rule if collide with actor
move speed 0
animate
move speed 100
This doesnt work. He just keeps moving and killing and never stops. What am I doing wrong? Thanks for any help.
Best Answer
-
JohnPapiomitis Posts: 6,256
Was in the middle of something when i posted before. Two things.
Are you moving or destroying the enemy actor when hes hit? if you leaving him in place, hit will never change back to false cause hell be constantly colliding with him. SO you can give him a self attribute called hit, change that to true when he collides, and then when thats true destroy him or move him out of the way after however many seconds on his kill animation or whatever.
Also you should change hit to true as soon as you collide, then change it to false after 3 seconds on the main player.
I made you a quick demo
http://www.mediafire.com/?40p00tc8m13xn58
Answers
Instead of changing move speed to 0, change attribute: self.motion.linear.velocity.x to 0. Then change move speed back to 100 after animation. Another thing... If you don't have a timer for when to move back to 100 after death, it will change move speed to 0, animate and change move speed to 100 instantly (so it might not appear like it stops).
If a timer doesn't work, try the change attribute.
Hope this helps,
Jack McGraw
When you collide change attribute hit to true, and have a rule when attribute hit is true timer after however many seconds you want change attribute hit to false.
Also if your using accelerate youll probably need to add some drag to the actor, its under its physics attributes.
cheers
I tried this:
move speed 100
then new rule if collide w actor
timer for 3 seconds
change attribute self motion linear velocity x to 0
Just with that the monster still doesnt stop. Just keeps blasting through everything.
Try doing what @JohnPapiomitis mentioned.
I created a hit attribute
created rule when self.hit is false
move speed 100
created rule when collide with actor
timer for 3 seconds
change attribute self.hit to true
This gets him to stop at the correct time.
I tried placing a change attribute self.hit to false after this and it doesn't get him to move again.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User