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
\$\begingroup\$
\$\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\$– PhilippCommented Aug 19, 2017 at 15:21
-
\$\begingroup\$ I did get a useful comment down below, \$\endgroup\$– gudperson2Commented Aug 19, 2017 at 15:31
-
\$\begingroup\$ Please accept it as answer then. \$\endgroup\$– RafiwuiCommented Aug 24, 2017 at 12:11
Add a comment
|
1 Answer
\$\begingroup\$
\$\endgroup\$
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
}
}
}