0
\$\begingroup\$

So I have a sword animation and it attacks enemies and stuff but whenever I walk into a house scene I want it to disable. So it only is enabled in outdoors scenes

\$\endgroup\$
3
  • 2
    \$\begingroup\$ You might get more useful answers when you add more details about your implementation of this "sword" feature and what "disabling" it actually is supposed to do and not do. \$\endgroup\$
    – Philipp
    Commented Aug 19, 2017 at 15:21
  • \$\begingroup\$ I did get a useful comment down below, \$\endgroup\$
    – gudperson2
    Commented Aug 19, 2017 at 15:31
  • \$\begingroup\$ Please accept it as answer then. \$\endgroup\$
    – Rafiwui
    Commented Aug 24, 2017 at 12:11

1 Answer 1

1
\$\begingroup\$

Create some kind of scene controller and put it on a GameObject in every scene. In this controller you could set a variable which the sword (e.g.) can check on load and disables or enables itself depending on that.

public SceneController : MonoBehaviour
{
    public bool enableSword = true;
}

public Sword : MonoBehaviour
{
    private SceneController sceneController;

    public void Start()
    {
        sceneController = GameObject.FindGameObjectWithTag("SceneController") // You need to create and set this tag in this case
        if (sceneController.enableSword)
        {
            // Do stuff
        }
    }
}
\$\endgroup\$

You must log in to answer this question.

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