Telekinesis game: problem for moving blocks

Hello all, I am working on a “telekinesis game” and I have some problems to move RigidBody.
I am using that code to move my object:
[java]if(geomToGrab != null)
Vector3f loc = geomToGrab.getControl(RigidBodyControl.class).getPhysicsLocation().clone();
if (aleft) {
if (aright) { loc.setZ(loc.getZ()+0.005f);
geomToGrab.getControl(RigidBodyControl.class).setPhysicsLocation(loc); }
if (aup) { loc.setY(loc.getY()+0.005f);
geomToGrab.getControl(RigidBodyControl.class).setPhysicsLocation(loc); }
if (adown) { loc.setY(loc.getY()-0.005f);
geomToGrab.getControl(RigidBodyControl.class).setPhysicsLocation(loc); }
(I know this code is uggly, but it’s only for testing)
The object move prfectly but it passes through the wall, floor,…
How can I do to “prevent” my object to pass through my physics scene ?

Thanks for all, Toogy
(sorry for my bad english)

I would suggest that you set your object to kinematic mode, and then use a sweep test (can be a bit flakey sometimes) to check for upcoming collisions.

Are you wanting to push physics objects with a force or just simply move a “floating” object around that has no physics?

If you are trying to actually simulate kinetic forces then you want to use applyForce or applyImpulse, etc.

1 Like