- Home /
[VIDEO]how to collision.transform.parent = transform.position ?(Parenting)
Hello,
I am struggling getting this to work. I want it like this:
As you can see it is working, however, I dont want tranform.scale
to go scale with the object. Only the transform.position
Here is the code of the "rope" wich is colliding with the gold
void OnCollisionStay(Collision collision) {
if(collision.gameObject.tag == "Gold"){
collision.transform.parent = transform; //here I want tranform.position
goBack = true;
extend = false;
}
Debug.Log("STAY");
Debug.Log(deltaRemaining);
}
if I do this:
collision.transform.parent.position = transform.position;
I get an NullReferenceException error.
Cheers,
Levi
Comment
Best Answer
Answer by Seizure · Sep 19, 2013 at 04:41 PM
Instead of
collision.transform.parent.position = transform.position;
do
collision.collider.gameObject.transform.position = transform.position; //This will make the collided objects position the same as the gameobject that this script is attached to