- Home /
Is it possible to zero out the transform component?
Just a quick question, is there a way to zero out the transform and rotation in the inspector for child gameobjects? I want to animate a gun that has many different parts, and all of those parts have these small differences in position and rotations and would like all of them to be the same at 0 just to make things more neat. Thanks for any responses.
Answer by Bunny83 · Mar 25, 2018 at 03:41 AM
I'm not sure what you mean by "zero out". You didn't really explain your question in detail so it's difficult to answer it. I was struggling if i should reject the question or not.
I just assume you mean that you want to set the local position and rotation to (0,0,0)? In this case you just do
Transform someTransform;
// [ ... ]
someTransform.localPosition = Vector3.zero;
someTransform.localEulerAngle = Vector3.zero;
If that's not what you meant you should edit your question and be more specific and clear about what you want to do. "zero out a transform" doesn't have much meaning to me and would belong in the group of "filling a wall", "throwing blue on the ground" and "writing a stone" which all doesn't make much sense ^^. Maybe it's a language barrier. I'm not a native english speaker.
@Bunny83 Sorry I was not very clear, you are right. I am trying to animate a gun with many parts, and they all have these small transform differences in the inspector. So I would like to get them to not change position but reset the transform components to 0 so it would make animating them easier.
I don't know how I forgot about localPosition and localRotation, thank you so much!
Your answer

Follow this Question
Related Questions
Keep position.z always at 0 2 Answers
A cubes most positive and negative x values 1 Answer
Scaling animation issue on build. 0 Answers
How to find a rotation of a child object 0 Answers