• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Stop objects and clear all forces

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

9 replies to this topic

### #1Martin Perry  Members

Posted 14 July 2014 - 09:47 AM

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

### #2Buckeye  GDNet+

Posted 14 July 2014 - 02:08 PM

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, 14 July 2014 - 02:12 PM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

### #3Martin Perry  Members

Posted 15 July 2014 - 03:03 AM

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).

### #4Buckeye  GDNet+

Posted 15 July 2014 - 05:37 AM

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, 15 July 2014 - 05:38 AM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

### #5ferrous  Members

Posted 15 July 2014 - 02:17 PM

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.)

### #6Martin Perry  Members

Posted 16 July 2014 - 03:16 AM

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

### #7ferrous  Members

Posted 16 July 2014 - 08:10 AM

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

### #8Martin Perry  Members

Posted 16 July 2014 - 08:34 AM

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, 16 July 2014 - 10:09 AM.

### #9JohnnyCode  Members

Posted 16 July 2014 - 04:22 PM

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

### #10Ashaman73  Members

Posted 17 July 2014 - 01:53 AM

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.

Ashaman

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.