i can't make a actor stop with change velocity?

guillefaceguilleface Member Posts: 1,014
edited March 2012 in Working with GS (Mac)
hi all, i have my actor changing velocity to random (0,360), speed=120, but when this actor collides with "hero" i want the actor to change position to top of the screen and to no longer moves, i try creating a self attribute, when move. is true to change velocity to 120, when move is false to change velocity to 0. so i set the rule when this actor collides with hero to change "move" to false, but it keeps moving, i try also to change x and y linear velocity to 0, constraining x and y position to a specific location but no matter what this actor keeps moving. i just need this actor to change x and y position to top of the screen and not to move after it collides with my hero.

Best Answer

  • CodeMonkeyCodeMonkey Posts: 1,803
    Accepted Answer
    If it has physical collision(with the collide behavior) then the collision may be changing the linear velocity. Also if there is any gravity or accelerate behaviors affecting the actor then that might be changing the linear velocity as well.

Answers

  • MotherHooseMotherHoose Member Posts: 2,456
    several ways to do this …

    simplest:

    [optionKey] + drag the prototype to make a copy of the moving actor
    name it movingActor2 or whatever … and delete all the rules/behaviors on it

    on movingActor
    Rule: when
    Event: overlaps/collides with hero
    --Spawn: movingActor2 at the correct X and Y relative to scene
    --Delete this actor
    Otherwise:
    --changeVelocity behavior

    image MH


  • guillefaceguilleface Member Posts: 1,014
    pretty much MS i did something similar, i decide to destroy the actor when it collides with my hero and to set a rule to true, so when this rule is true i have a same actor with a rule that when the attribute is true to change alpha to 1, this works great exept that i have to use destroy, but i have no more than 10 destroying actors on my scene so i hope is good, thanks everyone. but i still will try later to make this actor to stop because it should stop if i change velocity to 0..
  • bloomerbloomer Member Posts: 53
    I found a really good way to fully stop an actor who has several forces affecting him (for instance, linear velocities are set and there's an accelerate rule constantly sending it after another actor) is to just set its Maximum Speed to 0 and make sure Apply Max Speed is ticked. This will slap it to a halt immediately.

    In your case, you could do the above, then just change the hero's x and y to the top of the screen.

    The total halt trick doesn't suit all situations but it sounds like it might help here.
Sign In or Register to comment.