Rick Posted January 13, 2010 Share Posted January 13, 2010 Is there any way to basically set the position of a physics object continuously and still have it's physics work? We all know using SetPosition() on a body stops physics from working. So how can I simulate a set position on a body? I want to be able to set the position of a cube I have a physics body attached to and still have that physics body react to physics (ie, if a character jumps on it, the character won't fall through it. I don't have a mass on this physics body so it's like a floating cube in the world that I want to alter it's position yet still have the character controller able to stand on it) Quote Link to comment Share on other sites More sharing options...
Josh Posted January 13, 2010 Share Posted January 13, 2010 1. Use the calcomega and calcvelocity commands to calculate two vectors. Multiply these by the object mass, then add them as torque and force. 2. Use a static body you move around, and connect the dynamic body to it with a fixed joint. You can probably come up with a function using technique 1 that is like SetPosition or SetRotation, but with physics forces. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Rick Posted January 13, 2010 Author Share Posted January 13, 2010 These cubes will always have a mass of 0 and will never twist or turn, just move forward/backward/left/right/up/down. So I assume I only need to mess around with the force value then if applied directly to the center of the physics body as I assume that shouldn't cause any sort of twisting of the object? I should have probably listened in physics class. Quote Link to comment Share on other sites More sharing options...
Niosop Posted January 13, 2010 Share Posted January 13, 2010 If the mass is 0 then applying a force won't do anything. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Rick Posted January 13, 2010 Author Share Posted January 13, 2010 Damn. So I assume I have to give it a mass and apply equal force on all sides to make it float? Then I guess I adjust the force on a given side to move it a certain direction? Essentially I want to be able to move this cube to pivots that I place. Quote Link to comment Share on other sites More sharing options...
Volker Posted January 13, 2010 Share Posted January 13, 2010 The tests I made with storing the velocity and omega of an body, then position it and restore both again, were promising. Perhaps worth a try. Quote Core2DuoE6570 / Windows7 64bit / 4 Gb RAM / Geforce GTX 260 896Mb / LE 2.3 Dell Inspiron 1720 / Vista SP2 / C2D 2.4 / 8600 GM Link to comment Share on other sites More sharing options...
Niosop Posted January 13, 2010 Share Posted January 13, 2010 What do the platforms do? Are they just for your character to stand on? If so you could use a mass 0 one and SetPosition(). You might need to add a raycast from your character downwards and see if he's on a platform. If so, then adjust his height manually. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Niosop Posted January 14, 2010 Share Posted January 14, 2010 Hmm, maybe give it a mass, but create a slide joint between it and the pivot so that it doesn't fall or go off track. Then you just apply some force to move it. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Josh Posted January 14, 2010 Share Posted January 14, 2010 http://leadwerks.com/wiki/index.php?title=CalcBodyVelocity Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Rick Posted January 14, 2010 Author Share Posted January 14, 2010 I think I'll give your number 2 a shot. Seems easier. "Use a static body you move around, and connect the dynamic body to it with a fixed joint." I never played around with physics joints. Is the Vec3 in CreateJointFixed() a relative position from the parent or is it a global position? Also, if I make the parent body the one I move around, I assume the joint moves with it? So in my moving platform I would make a body that I move with SetPosition(), and another body positioned above my first body. Then create a joint where the first body is the parent and the second body is the child? Quote Link to comment Share on other sites More sharing options...
Rick Posted January 15, 2010 Author Share Posted January 15, 2010 I got this working btw, and it's freaking sweet. I made some supporting Thingoids to make it able to be more dynamic. I have a Cube Thingoid that has a physics body and you can apply a material to and resize. I have a Body Thingoid that does basically the same thing but is just a body. I have a Fixed Joint Thingoid that you assign 2 targets to. Target 0 is parent, target 1 is child. I have a Pivot Thingoid that creates a pivot at the location of the object in the editor. I have a MoveTo Thingoid. Target 0 is the body to call MoveEntity() on, and all the other targets will be the Pivot thingoid so it moves between pivots. It's really cool being able to just move the pivots around and see the cube move in any direction I make it, real-time!!! I'm excited. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.