-2
\$\begingroup\$

I wanted a shield around my player when my player picks it up. Now shield component is a child of object of player which is disable at start. I wanna enable it from the shield prefab. This is all in unity

How can i do that?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$
shieldGameObject.SetActive(true);

You can read about it here: https://docs.unity3d.com/ScriptReference/GameObject.SetActive.html

\$\endgroup\$
2
  • \$\begingroup\$ It should be noted that if you want to enable/disable a specific component on a GameObject, you do that with component.enabled = {true/false}, e.g. shield.enabled = true; \$\endgroup\$
    – Kevin
    Apr 13, 2021 at 1:37
  • \$\begingroup\$ It MAY be noted, since it isn't his question. \$\endgroup\$
    – Ofir A.
    Apr 14, 2021 at 2:13

You must log in to answer this question.

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