0
\$\begingroup\$

Im making a 3rd person 3D game. I have a little capsule shaped player controlled drone at the moment that moves on a flat surface. Y axis is locked. The Game object contains a script and then the child objects which are the actual body parts. If i attach a rigidbidy to the root object i get crazy results. The drone collides with something and starts to spin and then forward becomes some upward direction.

Somehow i would like to be able to use the pysics collision and ragdoll effects but still be able to maintain the keyboard movement. I guess that id have to animate the drone getting back up again when fallen.

Movement code

    void CheckForKeys ()
{
    if (Input.GetKey(KeyCode.W)) {          
        transform.Translate(Vector3.forward * Time.deltaTime * walkingSpeed);           
    }

    if (Input.GetKey(KeyCode.S)) {          
        transform.Translate(Vector3.back * Time.deltaTime * walkingSpeed);          
    }

    if (Input.GetKey(KeyCode.A)) {          
        transform.Rotate(Vector3.up * Time.deltaTime * rotatingSpeed);          
    }

    if (Input.GetKey(KeyCode.D)) {          
        transform.Rotate(Vector3.down * Time.deltaTime * rotatingSpeed);            
\$\endgroup\$
  • \$\begingroup\$ You could, rather than just translating the object, apply a force to it instead. That should remove some of the issues with the RigidBody. \$\endgroup\$ – Polar Nov 19 '13 at 23:24
  • \$\begingroup\$ I think you must have problems with your colliders. Which objects have colliders in your drone object hierarchy? If the root and child objects have colliders that intersect from the beginning, the physics can present weird behavior. \$\endgroup\$ – dsilva.vinicius Nov 21 '13 at 14:56
  • \$\begingroup\$ @dsilva.vinicius yes this is definitly what happened. Thanks! \$\endgroup\$ – Daarwin Nov 21 '13 at 14:59
0
\$\begingroup\$

If the root and child colliders intersect from the beginning the physics can present weird behaviour.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.