Menu Close

9/20/17 Opening and Closing Door

My screencast of opening and closing a door that I uploaded to Youtube. When you click the “closed door,” it sets the “open door” true, and sets the closed door false. Clicking the now active open door does the opposite.

Script OpenDoor:

sing System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class OpenDoor : MonoBehaviour 
{
    public GameObject Open;
    public GameObject Closed;

    void OnMouseOver () 
    {
        if (Input.GetMouseButtonDown(1))
            Open.SetActive(true);
        
        if (Input.GetMouseButtonDown(1))
            Closed.SetActive(false);
    }
}

 

Script CloseDoor:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CloseDoor : MonoBehaviour 
{
    public GameObject Open;
    public GameObject Closed;

    void OnMouseOver () 
    {
        if (Input.GetMouseButtonDown(1))
            Closed.SetActive(true);

        if (Input.GetMouseButtonDown(1))
            Open.SetActive (false);
    }
}

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *