Moving, stopping then moving again

PoisonCoyotePoisonCoyote Member Posts: 9
edited May 2012 in Working with GS (Mac)
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.

Best Answer

  • JohnPapiomitisJohnPapiomitis Posts: 6,256
    edited May 2012 Accepted Answer
    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

  • jckmcgrawjckmcgraw Member Posts: 647
    @PoisonCoyote

    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
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    edited May 2012
    Just make an attribute called hit, and have your accelerate behavior in a rule when attribute hit is false.

    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
  • PoisonCoyotePoisonCoyote Member Posts: 9
    Should I be starting with the move command?

    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.
  • jckmcgrawjckmcgraw Member Posts: 647
    @PoisonCoyote

    Try doing what @JohnPapiomitis mentioned.
  • PoisonCoyotePoisonCoyote Member Posts: 9
    Ok we are making progress. I attempted what @JohnPapiomitis said and it got my monster to stop at the correct spot. I just cant get him to move again after 3 seconds.

    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.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    If your change attribute self.hit to false behavior is in the rule with the condition when self.hit is false, it won't run after you change self.hit to true. Try wrapping the change attribute self.hit to true inside of a timer with a short # of seconds (e.g. 0.1) and check "Run to completion" so that it runs even when the initial condition is no longer true.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • PoisonCoyotePoisonCoyote Member Posts: 9
    @JohnPapiomitis that worked perfectly! Thank you very much for the demo. I did not need to have the dying actor to remain so I just allowed him to be destroyed. Also, I set the hit attribute just local to the monster himself. Is there a reason why you made it global? It seems to work the other way too. Thanks again to all of you for your help. I am learning a lot and getting close to completing my first game. Very exciting.
Sign In or Register to comment.