Moving Physic-Objects

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
schulzor2004
Posts: 29
Joined: Mon Jan 12, 2009 2:43 pm

Moving Physic-Objects

Post by schulzor2004 »

Hallo,

I have a very simple question, but I do not get it running, as I want:

I simply want to move an Entity by a program, let's say a platform, that goes up and down automatically. When I use the move or moveTo function on that entity, the physic seems not to work properly. For example, when something hits the platform it is not moved up or down correctly. The I tried to simulate the moving by using the velocity function. That worked, but it is not as correct, as using move.

So how do I move entity objects correctly?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Moving Physic-Objects

Post by Norbo »

One way to do it is to set the linearVelocity based on how much you've moved it. For example, before you move, store the entity's internalCenterPosition. Move the object and get the difference between the new and old positions. Divide this vector by the timestep (space.simulationSettings.timeStep) and you'll have a velocity that you can set the entity's internalLinearVelocity to.

This isn't completely accurate since it's always operating on the last frame's information, but it's significantly better than having no velocity input at all.

You could also do the reverse and compute the exact velocity necessary to make a move in the next frame that takes the platform to the desired location. This might be a little trickier to fit into your system depending on how it is set up, but it is an option.
Post Reply