Hey there Unity community! I've been working quite hard on a project lately with some colleagues, and I've just ran into something that I think might be a Unity bug itself. Anyways, I would love you to have a look at it and tell me if I've stuck my foot in at any point. This is the function causing the error:
public void _Place (Transform a_parent, Vector3 a_coordinates, bool a_beKinematic = false)
{
transform.parent = a_parent;
transform.localPosition = a_coordinates;
rigidbody.isKinematic = a_beKinematic;
//No parent, so the pickable is dropped
if (a_parent == null) {
transform.localEulerAngles = DropRotation;
} else {//Parented, so the pickable is equipped
transform.localEulerAngles = EquipRotation;
}
}
The point of the function is to parent / unparent the gameObject with this script attached to the one passed as a parameter. Because of some weird reason, when transform.localEulerAngles = EquipRotation happens (IE, the object has just been parented), the child (the gameObject running the script) changes its scale both numerically (which would make sense, given the fact that it has just been parented by an object with a scale different from (1,1,1)), AND graphically. This is, not only does it apply the localScale it should apply when being parented, but it also changes its global scale when set its localEulerAngles property.
This happens for setting both localEulerAngles and localRotation. If I comment out that line, everything works fine. I'm going nuts. Can somebody help me out?
Thanks beforehand
↧