- Home /
How can I attach a gameobject to another without changing its scale.
Im using a grenade that can stick to certain enemies, problem is sometimes the grenade scale gets messed up by the enemy scale, is there to attach a gameobject to another without missing its scale?
Right now im using some code like this:
onCollisionEnter(Collision col){
grenade.transform.parent=col.collider.transform;
}
Answer by Loius · Aug 13, 2012 at 04:50 AM
Try setting grenade.transform.localScale = Vector3.one after changing its parent. Not sure if that'll work.
If that fails, you can set the scale to the inverse of the parent object -
grenade.transform.localScale.x = 1.0 / parent.transform.localScale.x;
Same for Y and Z.
Your answer
Follow this Question
Related Questions
Make gameobject a child without affecting scale? 1 Answer
Problem with child and parent. 1 Answer
Extremely Fast Travel 1 Answer
Parenting from code doesn't really change the hierarchy 1 Answer
parenting instantiated object 2 Answers