Little issue with Velocity

synthesissynthesis Member Posts: 1,693
edited November -1 in Working with GS (Mac)
Having trouble fool-proofing actors stopping after dragging out of velocity. The premise is...I am doing a physics test...

Step 1: launch a ball at another ball using a launch trigger attribute (connected to a button).
Step 2: At launch, I change velocity on the ball to 250 and apply a drag of 100 and .02 angular.
Step 3: when the ball's linear velocity of X and Y is less than 10, I change velocity to 0.
(I've also tried forcing all of the actor's velocity attributes to 0)

Steps 2 and 3 are applied to both the shooter ball and the target balls (to collide with)

The shooter ball basically stops and my verification switch activates (a testing switch of the linear velocities that they are indeed below 10).

However...most of the time...if I let it sit for a few seconds...the balls tends to twitch a pixel or 2 here and there.

Is this a bug or am I missing something here?
Anyone have a suggestion of how to foolproof this and get the balls to absolutely stop when their individual velocities are at zero (or near zero)?

Comments

  • synthesissynthesis Member Posts: 1,693
    After several hours of futzing with this, about the only thing I can figure out to do with this is to spawn a new actor into the same place and then delete the current actor.

    Otherwise...the twitching will not go away. In tracking the values...I have noticed that after all of the physics are done, the lateral velocities dance around -1 and -2 and the rule parameters detect this but I can't seem to force the velocities to 0.

    I am not sure what is causing the values to cycle/twitch.
    The only way I can figure out how to reset a velocity to 0 (after a shot) is to clone and destroy.

    If anyone out there has a cleaner solution...I'm all ears!!!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    You have access to Motion.Linear.Velocity.X and Motion.Linear.Velocity.Y...

    When they get between -1 and 1, clamp them down to 0

    Rule
    ALL
    When self.Linear.Velocity.X < 1
    When self.Linear.Velocity.X > -1
    When self.Linear.Velocity.Y < 1
    When self.Linear.Velocity.Y > -1
    Change Attribute self.Linear.Velocity.X To: 0
    Change Attribute self.Linear.Velocity.Y To: 0

    You can change -1 and 1 to be as sensitive as your needs require...
  • synthesissynthesis Member Posts: 1,693
    Believe me...I tried that...about a hundred different ways...
    It doesn't seem to override the value.

    Sometimes they behave correctly on a test play...but rarely.
    I've also tried changing velocity to zero.

    The only way I have found to have 100% successful control is to clone and destroy.
    Its sooo weird. Logically it seems it should work as you describe...but I can't seem to get it to do it more than 5-10% of the time.
  • synthesissynthesis Member Posts: 1,693
    I have published a version of this test with the bug.
    http://gamesalad.com/game/play/42356

    If we can figure this out...it could be a clean tutorial resource for others for a table top shooting element.
  • JamesZeppelinJamesZeppelin Member Posts: 1,927
    Needed this info myself and when i tried what FMG said it worked perfectly

    came right to a halt

    Tested it out by adding the rule he made to codemonkeys pool game
Sign In or Register to comment.