# Stop objects and clear all forces

This topic is 1614 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have objects that are sliding on a tilt plane (under teh angle of 30°). When they reach the end of the plane, I would like to clear all forces and let objects fall directly down with only gravity affecting them.

Currently, all my objects continue to move in a direction of plane´s tilt and are "slowly" pushed down by gravity (the speed of push down depends on objects speed and mass).

How to achieve such a behaviour ? And is it even possible ?

Thanks

##### Share on other sites

my objects continue to move in a direction of plane´s tilt and are "slowly" pushed down by gravity (the speed of push down depends on objects speed and mass).

That's how it should work, except the "push down" doesn't depend on speed. Force = mass * gravitational_constant. They continue in the direction of the plane's tilt because they have horizontal and vertical speed built up from sliding down the ramp. If there's no horizontal force acting on them after they fall off the end of the ramp, they will continue in the horizontal direction at the same speed. The vertical speed will increase as gravity accelerates the object.

If you just want them to "fall off" the edge unrealistically, detect when the object's position is just beyond the edge of the plane and set the object's horizontal and vertical speeds to 0. If you've got things setup correctly, then, at that point, gravity will be the only force.

Edited by Buckeye

##### Share on other sites

There is a problem with this approach, how to find out, that objects is no longer above the plane and should fall. If I hard-code some conditions, it wont work universally. Also, setting velocity to 0 must be done only once - how to find out when - and not continuously (it deactivate gravity).

##### Share on other sites

You can put an invisible vertical plane just beyond the end of the ramp. That will zero the horizontal speed, but not the vertical. For that you can put a short horizontal plane at the end of the ramp.

I.e., final configuration: ramp, short horizontal plane, gap, vertical plane.

Edited by Buckeye

##### Share on other sites

You'll have to pardon my ignorance with bullet, but in Box2d you could do a check to see if the objects are in contact with the ramp, and if they aren't remove all but the downward force.  You might have to do a little fudging to only have this occur if the objects are under a certain value, so that if they bounce up off the ramp before hand they don't suddenly stop moving in any other direction.

Doing the invisible plane thing might work, but you'd definitely see a bounce if anything was sliding fast.  (for slow objects, it probably is fine.)

##### Share on other sites

Well.. I have tried to find out something that indicats, that objects are in contact with something, but found nothing.

##### Share on other sites

Well.. I have tried to find out something that indicats, that objects are in contact with something, but found nothing.

##### Share on other sites

Well.. sort of :-) I will have to add some other info to my SceneObject and with that it should work. Thanks for now

EDIT: Ok.. I have condition and succesfully tested if objects left the plane. But calling clearForces has no effect. How to do it other way?

Edited by Martin Perry

##### Share on other sites

you should consider friction. Only force that aplies over your objects all the time (in your scenario) is gravitation atraction force, AND, friction eliminating force.

If your object seem to slide at extreme speed resulting in unrealisticc platform donated outer propagation, you are making your object slide a 30 degrees perfect ice smotth platform. (I have crashed my head at such a thing as little brat)

Results are rather strange efect.

If you were free falling towards a point, and colapssed a ground before it with a perfect friction,  you would propagete to the pont with same speed still!- thus creating extreme advenced aside movement! (creating an impossible result even physicaly, but phenomenaly existing)

see friction in bullet, straightly compared to weight, tendence and potential

##### Share on other sites

But calling clearForces has no effect. How to do it other way?

You need to do two things:

1. Detect that you dont hit the ground any longer:

Either check contacts or use raytests. Bullet supports contact manifolds and ray casting. To avoid some miss-behavior for bouncing objects, I would check the last 2 frames, that is, you have ground contact only if you detect a contact this and in the last frame.

2. Nullifying the forces is only one part, you still need to clear the current velocity, thought you can keep the up-down (y-axis) velocity.

1. 1
2. 2
Rutin
19
3. 3
4. 4
khawk
14
5. 5

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633743
• Total Posts
3013643
×