Moving 3D physics object

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.

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #9302

    Hezkore
    Participant

    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?

    #9307

    Simon Armstrong
    Participant

    My 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.

    #9308

    Hezkore
    Participant

    I tried making a player movement class based on physics, but I have almost no control over the physics body :/

    #9310

    Simon Armstrong
    Participant

    So what do you mean based on physics – applyforce, applyimpulse, setlinearvelocity or what exactly?

    #9311

    Hezkore
    Participant

    Well 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.

    #9316

    Mark Sibly
    Keymaster

    Some 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!

    #9320

    Hezkore
    Participant

    Haha 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.

    #9321

    abakobo
    Participant

    You 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…

    #9322

    Hezkore
    Participant

    That 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!

    #9323

    abakobo
    Participant

    Disabling collision can work depending on the physics engine. Don’t know for bullet.

    #9326

    Mark Sibly
    Keymaster

    Games 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.

    #9327

    Hezkore
    Participant

    Oh, 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!

    #9328

    DruggedBunny
    Participant

    You 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…

    #9329

    Mark Sibly
    Keymaster

    I’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!

    #9330

    Ethernaut
    Participant

    Some “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.

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic.