Vive Vr Developing problem (Controllers Diapering because of script )
this script takes a Key and when it enters the game-object the script is attached to the key disappears and the chest lid swaps the other chest lid is able to be piked up with the vive controllers
using UnityEngine;
using System.Collections;
public class Keyandlock : MonoBehaviour
{
public GameObject Key;
public GameObject chestLid;
public GameObject chestlid2;
public GameObject Hand1;
public GameObject Hand2;
void start ()
{
chestLid.SetActive (true);
chestlid2.SetActive (false);
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Key")
{
Debug.Log ("Detected");
Key.SetActive (false);
chestLid.SetActive (false);
chestlid2.SetActive (true);
Hand1.SetActive (true);
Hand2.SetActive (true);
}
}
}
this is the second script doing the same thing but on a door.
using UnityEngine;
using System.Collections;
public class Door : MonoBehaviour
{
public GameObject DoorKey;
public GameObject Door1;
public GameObject Door2;
public GameObject Hand1;
public GameObject Hand2;
public GameObject Lock;
void Start ()
{
Door1.SetActive (true);
Door2.SetActive (false);
Lock.SetActive (true);
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Keyone")
{
Debug.Log ("Unlocked");
Door1.SetActive (false);
Door2.SetActive (true);
DoorKey.SetActive (false);
Hand1.SetActive (true);
Hand2.SetActive (true);
Lock.SetActive (false);
}
}
}
Whenever I Use the controllers to put the key in the trigger the controllers disappear. plz help Whenever i set the blank hand 2 on the first image to active i can then see the controller but none of its scripts are active.
I found out the controller was being .Setactive (false) because it was connected to the key when i put the key in the chest key hole so i set it so that the key would not have its .Setactive (false).
Answer by rapinnz · Jan 06, 2018 at 07:07 PM
please if anyone knows the answer. Im getting desperate.