Attaching a child gameobject to a gameobject pinned to a rope - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html) +--- Thread: Attaching a child gameobject to a gameobject pinned to a rope (/thread-1169.html) |
Attaching a child gameobject to a gameobject pinned to a rope - nigelkennington - 09-05-2019 Hi, I have a crane with a hook pinned to two obiropes. That's working fine, but I'm having a real problem when the crane hook "picks up" a different game object. If the game starts with the hook parented to a gameobject, everything is fine: but if I use the script to parent it while the game is running it behaves very oddly: Any idea what I am doing wrong? RE: Attaching a child gameobject to a gameobject pinned to a rope - josemendez - 09-05-2019 (09-05-2019, 03:48 PM)nigelkennington Wrote: Hi, Hi there, Tested in the Crane sample scene, but can't reproduce anything strange. Programmatically parenting to a pinned object works just fine for me. Can you share the code you're using to parent the second object? RE: Attaching a child gameobject to a gameobject pinned to a rope - nigelkennington - 09-05-2019 (09-05-2019, 04:02 PM)josemendez Wrote: Hi there, Thanks Jose, Here's the code: Code: private void OnTriggerStay(Collider other) All it's doing is counting down 3 seconds if the hook is inside the attachpoint, then setting the attachpoint's parent's parent to be the anchor of the hook and disabling the attachpoint. (09-05-2019, 04:20 PM)nigelkennington Wrote: Thanks Jose, I've taken the rigidbody off the child object and that seems to have fixed it. Thanks for trying to help though! RE: Attaching a child gameobject to a gameobject pinned to a rope - josemendez - 09-05-2019 (09-05-2019, 04:20 PM)nigelkennington Wrote: I've taken the rigidbody off the child object and that seems to have fixed it. Glad you figured it out! Parenting a rigidbody to another rigidbody does not make sense, regardless of it being pinned to a rope or not: https://answers.unity.com/questions/62497/-you-should-never-have-a-parent-and-child-rigidbod.html In newer Unity versions it *can* be done, but gravity will still affect the child rigidbody in world space, making it pretty much useless. Establishing spatial relationships between rigidbodies should always be done via joints. |