0
\$\begingroup\$

I am learning using the Explore Unity Course. In the picture you can see I've instantiated many hats from the same prefab.

I want to rotate the hat in prefab mode so that the change will apply to all hats, but the rotation property is inactive, as shown in the picture.

Why can't I edit the rotation property in prefab mode? Is there a way to rotate all the hats at once?

Editing hat prefab with rotation disabled

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

When you spawn a prefab instance, it gets its own position and rotation, so those properties are effectively overridden on all instances.

What you can do if you want to flip the hat upright is tick the "Flip X" and "Flip Y" checkboxes in the SpriteRenderer component - this will do the same thing visually as a 180 degree rotation.

If you want to be able to control rotation of all instances at once to a finer degree, you can set up a hierarchy like so:

  • Prefab root & rigidbody
    • Hat sprite & collider

Then you can rotate the hat visual within its parent, and all prefab instances will have their visible child rotate the same way, since only the root's transform is overridden by default.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks! The Flip way and hierarchy way both work well ! Also thanks for correcting grammar mistake of my question \$\endgroup\$ Commented Jun 5, 2023 at 11:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .