The above video is my screencast of the light-switch I made. The code for the light switch is exactly the same as when I made scripts to close and open a door. Just that I added a 3rd if statement, basically to add a 3rd reaction to, if something, happens.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TurnOnLightSwitch : MonoBehaviour
{
public GameObject SwitchOff;
public GameObject SwitchOn;
public GameObject Light;
void OnMouseOver ()
{
if (Input.GetMouseButtonDown(1))
SwitchOn.SetActive(true);
if (Input.GetMouseButtonDown(1))
SwitchOff.SetActive(false);
if (Input.GetMouseButtonDown(1))
Light.SetActive(true);
}
}
AND
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TurnOffLightSwitch : MonoBehaviour
{
public GameObject SwitchOff;
public GameObject SwitchOn;
public GameObject Light;
void OnMouseOver ()
{
if (Input.GetMouseButtonDown(1))
SwitchOff.SetActive(true);
if (Input.GetMouseButtonDown(1))
SwitchOn.SetActive(false);
if (Input.GetMouseButtonDown(1))
Light.SetActive(false);
}
}
After this I’m gonna work on creating a safezone, in which, when the player walks into it, his/her health will begin to regenerate.