1
\$\begingroup\$

enter image description hereenter image description hereI have made a ragdoll and attached (as child object) the main camera to it, but the camera doesn't follow the ragdoll. Why is this happening? And how do I fix this?

\$\endgroup\$
1
\$\begingroup\$

Your ragdoll, being attached to another object, is moving in the local space of that parent. Thus you have to make the camera a child of your ragdoll if you want it to follow. Read here for an existing answer: In Unity, how do I make the camera follow a character?

Having said that, don't do it but use a proper script where you set the ragdoll as target to compute the new camera position from. That will give you a much better control and user experience.

\$\endgroup\$
  • \$\begingroup\$ No the camera is attached to the ragdoll \$\endgroup\$ – AJ123 Oct 22 '16 at 8:13
  • \$\begingroup\$ No, the camera is attached to the ragdoll. Not the other way around. \$\endgroup\$ – AJ123 Oct 22 '16 at 8:15
  • \$\begingroup\$ Can you post your hierachy and inspector of the camera during play? I just tried it myself on the Tanks! example and the camera did move with the tank I made it child of. \$\endgroup\$ – Thomas R. Koll Oct 22 '16 at 11:32
  • \$\begingroup\$ I added the picture \$\endgroup\$ – AJ123 Oct 22 '16 at 12:02
  • \$\begingroup\$ We'll also need an inspector view of the player and the camera \$\endgroup\$ – Thomas R. Koll Oct 22 '16 at 12:52
0
\$\begingroup\$

For the ragdoll, add a Rigidbody component. The ragdoll is affected by physics and doesn't change its transform's position, adding rigidbody is a workaround cause it changes the transform whenever the ragdoll (parent) changes positions constantly. the ragdoll is affected by rigidbody but it is barely noticeable. Make a script or add a script that constantly changes the camera's position relative to the ragdoll (add some offset if you're doing third person or want the camera to be positioned onto the head). This should make it work.

\$\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.