Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Parented Grabbable Object hitting other rigidbodies issues --- SOLVED

pjennesspjenness Posts: 691
Neo
Hi

Im running into an issue where if I pickup a grabbable and swing it at a large phyics object, it hits and then judders.

For example a stick and a large ball:

If I swing a grabbable stick at the ball , the ball starts to move it then just stops. (like it is getting stuck)
But it only happens with held items

If I throw the grabbable object at the large ball it behaves correctly.

Im assuming its something to do with, the fact the object is parented to my grabber and that it ends up inside the ball for x frames and confuses the physics. But if thrown it separates from the hand and works like proper physics?
Drift VFX Visual, Virtual , Vertical

Want 970GTX on Macbook for good FPS?
https://forums.oculus.com/viewtopic.php?f=26&t=17349

Comments

  • pjennesspjenness Posts: 691
    Neo
    Ah, jsut reading the Grabber.cs

        // Demonstrates parenting the held object to the hand's transform when grabbed.
            // When false, the grabbed object is moved every FixedUpdate using MovePosition.
            // Note that MovePosition is required for proper physics simulation. If you set this to true, you can
            // easily observe broken physics simulation by, for example, moving the bottom cube of a stacked
            // tower and noting a complete loss of friction.
            [SerializeField]
            public bool
                m_parentHeldObject = false;

    Yeah this is exactly what Im seeing. If I unparent then the physics works perfectly, but motion is messed up.
    I wonder if it makes sense to separate the visual item fro the physics, and use  MovePosition on a colider only, and keep the renderable parented. So visually it looks correct, and phyics works correctly.

    -P

    Drift VFX Visual, Virtual , Vertical

    Want 970GTX on Macbook for good FPS?
    https://forums.oculus.com/viewtopic.php?f=26&t=17349
  • pjennesspjenness Posts: 691
    Neo
    edited January 2017
    OK.. success

    THe way Ive setup my objects is the Colliders are under a transform under my main object, and stored a reference to it. Can be multiple colliders as needed, under a single transform.
    The local position and rotation must be 0,0,0






    When I pickup a grabbable, I have an additional control (myGrabbable) component  that detects the grab, and it unparents the collider group (m_collidergroup) , creates a rigidbody on it and copies acros the desired values:

    if (m_grabbable.GrabbedBy.m_parentHeldObject) {

    Now the same myGrabbable component on FixedUpdate makes sure the separated collider group keeps up with the grabbable

                if (m_colliderGroupRB) {

                    m_colliderGroupRB.MovePosition (this.transform.position);
                    m_colliderGroupRB.MoveRotation (this.transform.rotation);

                }

                       
    }
    if (m_colliderGroup) {



    Once detected a release, remove the rigidbody and reparent

    if (m_colliderGroupRB) {


    The caviet is you need to probably on pickup setup ignore Collision on your local player as you may end up swinging a collider thru yourself that does engage physics as its not parented.

    You can use





    Im sure my code is terrible..but its working for now.

    Cheers

    -P




     



    Drift VFX Visual, Virtual , Vertical

    Want 970GTX on Macbook for good FPS?
    https://forums.oculus.com/viewtopic.php?f=26&t=17349
Sign In or Register to comment.