How do I stop physics objects from jiggling and moving around when they should have stopped moving?
Hymloe
Member Posts: 1,653
Hi,
I find that when I bounce an object around, it doesn't come to a complete standstill. It jiggles around indefinitely after coming to a rest. How do I stop this?
I am making a dice simulation. I have a dice actor which is square, and when I click it, I set it to have a high linear velocity X and Y, and angular velocity. It has Friction 10, Density 1, Bounciness 1, Drag 600 and Angular Drag 3.
It all behaves exactly as I want it to, except when it stops, it keeps jiggling around a bit. It sort of drifts in a jerky manner, jiggling left, right, up, down, just a little.
How do I stop this from happening?
I've tried using a timer to simply set the linear velocity x and y, and the angular velocity all to 0 after a few seconds, which you would think would work, but it still jiggles. So it doesn't seem to be anything to do with the actual velocities of the dice.
- Murray
I find that when I bounce an object around, it doesn't come to a complete standstill. It jiggles around indefinitely after coming to a rest. How do I stop this?
I am making a dice simulation. I have a dice actor which is square, and when I click it, I set it to have a high linear velocity X and Y, and angular velocity. It has Friction 10, Density 1, Bounciness 1, Drag 600 and Angular Drag 3.
It all behaves exactly as I want it to, except when it stops, it keeps jiggling around a bit. It sort of drifts in a jerky manner, jiggling left, right, up, down, just a little.
How do I stop this from happening?
I've tried using a timer to simply set the linear velocity x and y, and the angular velocity all to 0 after a few seconds, which you would think would work, but it still jiggles. So it doesn't seem to be anything to do with the actual velocities of the dice.
- Murray
Comments
when
linear velocity x and y,
and the angular velocity
is less than say 5 change it to 0
im sure that stopped the jiggle I have had in the past, but as i say, i dont have GS with me to check
You might also find an answer in this video a did about this same issue.
http://www.jamie-cross.net/?p=272
Jamie
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
That's a useful video.
But why would we need to do such a solution? I wonder what's wrong with the physics.
If the Linear Velocity X, Y and Angular Velocity are all 0, why would it be jiggling around, anyway?
Anyway, I might resort to your solution if I can't figure out why the physics system isn't just working as it's supposed to by itself.
Cheers! Very helpful.
- Murray
Ideally it would be great if setting the Velocities you mention to 0 stopped the movement but in my case it did not.
Let me know if it works out any better for you.
Good Luck!
Jamie
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
In THEORY, if the Linear Velocity X and Y are both 0, the object should not be moving right?
That's what the physics system SHOULD do, right? Any other behaviour, such as jiggling, can be seen as a bug, right?
Or am I missing something here?
- Murray
So would you suggest just checking for the actor coming to a "near standstill", and then constraining it to that X,Y position, as suggested above?
Or is there another option that doesn't involve a constrain, perhaps?
- Murray
Jamie
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Shall have to rely on workarounds until Game Salad address the issue with the physics system in a more elegant manner.
Cheers!
- Murray
I've tried constraining motion.linearvelocity X and Y to 0. That doesn't stop the jiggling.
So I've tried constraining the self.position X and Y to 0, and that doesn't work either!
I have my character rotate to face the motion.linearvelocity of the actor, so... seeing as the character is jiggling a bit, the art is flipping constantly.
My character has a constrain that says...
game.playerposX = self.positionX
game.playerposY = self.positionY
Is the bug to do with a feedback loop, because I'm trying to store the player's position to a global attribute, and then also force the player to be constrained BACK TO that global attribute as well, or something?
Is it an issue with my playerposX being stored as an integer? When maybe it should be a real? Is it translating back and forth from a real to an integer, and therefore jiggling?
- Murray
It just seems to not come to a clean stand-still.
SOOOO annoying!
Constrain:
PlayerFacingAngle = VectorToAngle(motion.linearvelocityX,motion.linearvelocityY)
Constrain:
self.rotation = PlayerFacingAngle
I think I have a problem with my VectorToAngle constraint, it seems to flip out when the character is not moving, because I guess it's trying to multiply by a 0, or by a negative number, as the character jiggles around, or something.
So I'm checking for then the character is moving, and only updating that PlayerFacingAngle then. If they're not moving (below a certain threshold), I just don't update which angle they're facing, so it doesn't flicker anymore.
The character's position still jiggles around a bit when it's meant to be standing still, but that's not really causing a bad problem visually, so I think I'll leave it.
Thought I'd post that in case it helps someone else one day.
- Murray
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Move behavior with:
Move Type: stacked
Speed: 0
worked like a charm and way less overhead than a bunch of constraints and rules..