Perfect Dead Stop

ORBZORBZ Member Posts: 1,304
Sometimes it's very frustrating in GS to get your actor to come to a full stop if it is controlled by physics.

It seems that this should work:

Change Velocity: 0

But it doesn't. The reason, as best I can determine, is that the physics engine carries over inertia into the next frame. So the above statement really only slows the object to a crawl.

A viable workaround that I use is this:

For 0.1s
Constrain Linear Velocity X = 0
Constrain Linear Velocity Y = 0

This results in a perfect dead stop because it forces the linear velocity X/Y to be 0 for a few frames of the physics engine, thus the inertia calculations zero out over time. Best as I can figure.

I really hope that @CodeWizard take a look at this and figure out why Change Velocity: 0 doesn't cause an object to come to a dead stop instantly. In the meantime, the above works.

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    I've always used Linear Velocity to stop my actors. Never used the Change Velocity behavior...Now that you mention it, that should work. It would be nice to have that fixed.
  • ORBZORBZ Member Posts: 1,304
    edited May 2013
    @Braydon_SFX

    The thing is, even if you use the linear velocity attributes to stop your actors. You MUST constrain them to 0 for at least 0.1s. If you just use Change Attribute then it only applies once and then you get a small drift.

    This is particularly nasty if you move an actor off stage for recycling and it drifts out of bounds and is automatically deleted by GS.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    It's surprisingly difficult to stop actors once they are moving.

    Seems like a good suggestion, @ORBZ.

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

  • SnapFireStudiosSnapFireStudios Member Posts: 1,603
    I've always used Linear Velocity to stop my actors. Never used the Change Velocity behavior...Now that you mention it, that should work. It would be nice to have that fixed.
    Same here. Not high priority for me, since there's an easy workaround. But it would be nice.
    - Thomas
  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2013
    @ORBZ

    Nice tip with the For 0.1s thing. :)>-

    I posted this the other day on the very same subject:

    http://forums.gamesalad.com/discussion/56981/are-these-fixestweaks-what-youd-want#latest
    I'd like to see the ability to enter some degree of noise into collisions (and elsewhere), it would be useful in removing 'digital' accuracy where a little 'analogue' vagueness would be preferable.

    Also a 'stop' behaviour would be very handy, a catch-all command that brings an actors movement, any movement, to a halt, I know it can be done by constraining or changing the X and Y velocity attributes and rotation attributes and so on, but it would be nice to have a simple 'stop' behaviour, it would be even better (and more useful) if it had some degree of dampening / ease out control.


  • HoneyTribeStudiosHoneyTribeStudios Member Posts: 1,792
    edited May 2013
    Yeah that can be annoying when something seems to keep moving when it shouldn't.

    It seems to be more of a problem when you combine different physics behaviors. If I'm doing that I 'cancel' all of them and that seems to work out ok.

    e.g in my game Yam Yam the fruit you flick has a change velocity behavior and also a constant downwards acceleration. When I pause the game (not using the pause behavior) they stop mid-air as you would expect them to.

    So the value for the accelerate behavior is something like game.speed*game.pause

    And game.pause is either 1 or 0

    And when pause = 0
    Change Linear Velocity X = 0
    Change Linear Velocity Y = 0

    http://www.youtube.com/watch?feature=player_embedded&v=FNQexOGvpwQ

    Multiplying move behaviors by 0 also works well to stop them.
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited May 2013
    Yes in I always find you need to

    For .2sec
    Constrain angular velocity to 0
    Constrain linear velocity x to 0
    Constrain linear velocity y to 0

    Having said that I just thought you could try change max velocity to 0 if you check it and put in a high number and change it to zero I bet it stops dead in it's tracks! You can modulate the max velocity during rumtime as long as you check max velocity in the actor and access the variable through the expression editor. I remember in Puck It where I modulate max velocity that one time during testing I had max set to zero and it was at a dead stop and nothing moved it even the paddle.
Sign In or Register to comment.