- Home /
transform.parent don't work with rigidbody?
So, I was creating a build menu for my game, everything works perfect except for attachment. I wanted to use it like this:
var follow : Transform;
function Update ()
//rest of the script
{
transform.parent = follow;
}
And it just don't work :/ If someone know a solution to this problem it would be awesome if you can explain to me what am I doing wrong :). Sorry for bad english.
For one, don't declare a parent in Update unless there is some condition you will be changing. Put this in Awake() or Start(). You only need to call it at startup right?
No, it have to be on update, because it is activating after something happend (Button is pressed). As I said i'm making building menu so I want to connect 2 objects together.
Answer by Xtro · Aug 06, 2013 at 08:59 PM
Rigidbodies doesn't respect the transform hierarchy.
for example, if you have two rigidbodies A and B, A parenting the B... They won't be linked. Each rigidbody moves seperately even if it's parented by another rigidbody.
If you really want to link them, you should use joints. by fiddling with the settings of the joint, you can make the link as strict or loose.
Thanks for explaining :) I just made some research for Fixed Joint and I finally made it working :) Thanks again you saved me like good few hours of searching.
Your answer
Follow this Question
Related Questions
Detect collision/trigger between two body without rigidbody? 3 Answers
How to lock X rotation; broken script 0 Answers
Modifying height directly on a Rigidbody Object without gravity 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
How to find the angle of a rotation? 1 Answer