How to move objects with collision detection

Hi Everyone
I am trying to allow my mouselook controlled player to move some blocks inside the game. Initially I had success by re-parenting the objects to the player. However this allowed me to move the objects through other objects or walls, this is undesirable.
So I figured applying forces to the object will be more natural and allow the physics system to do collision detection.
So I tried using a servo actuator, but It seems it can only be used to control relative velocity, not position?
I thought that if I set the relative velocity reference to zero then when my player moves, the object should start moving to maintain the zero relative velocity. However this didn’t work as desired, if the player moves then nothing happens but if the object moves(by being bumped by another object) then the servo actuator will quickly make it come to a stand still.
I tried using the constraint actuator but that didn’t work either.

I guess the only way to do it is to apply forces manually via a python script, or is there another way?
Also any hints on how to make the python controller would be appreciated:D

Thank You!

Are you trying to make like a Half-Life 2 physics system? (just wondering, I can help better if I know your desired result)

here check this out :slight_smile:

Attachments

WRectification.blend (779 KB)

@MichelleSea well, right now im trying to make something like a puzzle game where you can move different physical objects around and try to make them fit together.

@BluePrintRandom Thank you :), im not sure I understood your blend file but I think you put some collision boxes on the arms right ? That way if the player grabs something with their arms, they will still be constrained to by the bounding boxes of the arms, but I think this might not work depending on the shape/size of the object.

Ok, by implementing a PID controller(which applies a force to the object) in python that tracks the position error between the object and a point in front of the player(thats parented to the players camera) I got it to work, here is the blend file for anyone interested.
Simply walk up to one of the cubes, center the camera over one of the cubes and hold down right mouse button. You should now be able to move the cube by moving your mouse or player(wasd) and it should collide with other cubes and the floor.
There is a bug though in that its too easy to switch between the cubes but the main idea works.

Attachments

handGrab.blend (383 KB)

The object is a rigid body, pinned to a empty the empty gets parented to the “center” this makes the item physical and movable :slight_smile: