I have two scripts and in one I want, under a certain condition, to give a command to start an action in another script.
public class joystickMove : MonoBehaviour
{
public Text LivesUI;
int Lives = 3;
public void Init()
{
Lives = 3;
LivesUI.text = Lives.ToString();
gameObject.SetActive(true);
}
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag == "EnemyTag")
{
PlayBoom();
Lives = Lives - 1;
LivesUI.text = Lives.ToString();
if (Lives < 1)
{
DeadScreen.SetActive(true);
RestartButton.SetActive(true);
Destroy(gameObject);
}
}
}
}
How do I now run the Lives = Lives - 1;
action in another script under a certain conditions?
2