About Monkey 2 › Forums › Monkey 2 Programming Help › Moving 3D physics object
This topic contains 15 replies, has 6 voices, and was last updated by
Mark Sibly
1 year, 9 months ago.
-
AuthorPosts
-
July 13, 2017 at 7:38 pm #9302
I’m trying to move a physics (bullet module) object around, but it keeps teleporting back to its original position.
And there doesn’t seem to be any way to move the body of the physics object.
How do I set its position?July 14, 2017 at 1:02 am #9307My guess would be to create a new body at the new location. Moving stuff without using physical force will just break stuff in most physics simulations.
July 14, 2017 at 1:04 am #9308I tried making a player movement class based on physics, but I have almost no control over the physics body :/
July 14, 2017 at 1:58 am #9310So what do you mean based on physics – applyforce, applyimpulse, setlinearvelocity or what exactly?
July 14, 2017 at 2:21 am #9311Well I meant using the bullet module that comes with M2.
But yeah, all that, and also set position, which would be required for positioning the player correctly at start.July 14, 2017 at 11:05 am #9316Some kind of ‘player object’ is the next thing I need to attempt physics-wise.
You can currently create static, dynamic or kinematic rigid bodies – see the ‘shapes’ test: The ground is static, the objects are dynamic and the camera is kinematic. But none of these really suit game style player objects – dynamic bodies need to be moved using ‘impulse’ forces which is pretty nasty (basically like poking an object with a stick to make it move! I will add support for impulse forces though), and kinematic bodies don’t respond to collisions with other bodies at all, they are more suitable for things like platforms etc.
Player objects really need to be hacked in using raycasting or something similar as they generally break all the laws of physics!
July 14, 2017 at 1:59 pm #9320Haha okay.
I would recommend firing up any of the Quake games and study their movement style as the base.But let’s say I just want to throw a ball from the camera.
Every time I press the left mouse button, the ball resets to the cameras position and shoots out.
I’d need set position for that too.July 14, 2017 at 3:57 pm #9321You are not supposed to move dynamic bodies this way, it would create/induce very strange things energy/space/time wise. You should destroy it before making it appear somwhere else…
July 14, 2017 at 4:25 pm #9322That seems like a major waste…
Disable collision, place body at new position, enable collision, seems like a better idea.
But alright, I’m no expert.
There’s no way to add/set velocity or rotation or anything yet though, so I guess “throwing a ball” isn’t possible just yet anyways.Thanks everyone!
July 14, 2017 at 7:31 pm #9323Disabling collision can work depending on the physics engine. Don’t know for bullet.
July 14, 2017 at 11:06 pm #9326Games like quake don’t really use ‘physics’ at all – they have a simple collision detection/response system and that’s about it. As such, environments are largely static and objects don’t move in very physically realistic ways – players run around with infinite acceleration/deceleration etc and it’s all very surreal. Fun though of course!
Quake (and b3d) handle collision/detection via raycasting, and this is probably where I’ll start (bullet has raycasting features I can use) but it isn’t really ‘physics’ in any meaningful sense. I would definitely like to see more physically correct/realistic stuff possible in mojo3d though.
July 14, 2017 at 11:22 pm #9327Oh, I didn’t know bullet had raycasting, that’s even better.
Are bullet raycasting available right now, or will you have to add that later?
I’d love to get started on some player movements!July 14, 2017 at 11:32 pm #9328You should destroy it before making it appear somwhere else
…
Disable collision, place body at new position, enable collision, seems like a better idea
Whatever works best with Bullet, I’m sure it could be wrapped in a nice “Entity.Warp”-type command that takes care of the ugly details of manually repositioning an entity within the physics system!
Pretty sure that Newton allowed manual repositioning of physics objects, so ought to be do-able one way or another…
July 15, 2017 at 1:39 am #9329I’ll be able to add/fix (probably should be working…) repositioning of physics objects, but it’ll only really be useful for ‘reseting’ object positions etc. (which may be want you meant). Simply ‘warping’ something into a colliding state will likely cause bullet to resolve the collision in a weird/unrealistic way.
The idea of physics simulations is really to let them deal with integrating (ie: updating) positions, velocities, accelerations, torques etc on their own, so they can deal with resolving collisions etc in as realistic a way as possible. Things don’t ‘warp’ so simulators don’t like this – you’re really supposed to apply impulse forces if you want to move something in an instantaneous (ie: game like) way.
I think the best thing I can do is to add commands for dealing for raycasting, impulse forces etc and let people play with it all!
July 15, 2017 at 2:14 am #9330Some “player object” system (sometimes called “Arcade Physics”, since it’s designed for non-realistic movement) that still collides/reacts to some degree with physics objects would be amazing! It was one of my main gripes with Unity3D, dealing with Physics and “Character Controller” movement didn’t feel like a fully integrated system.
-
AuthorPosts
You must be logged in to reply to this topic.