Using Multiple Activated Triggers to trigger a Separate Event.
Hey all,
I'm trying to prototype a mechanic whereby multiple objects (cubes) must be placed in the correct place at the same time, to trigger a separate event, such as a door opening. The door can only open if all of the objects are in the right place at the same time, meaning all triggers must be on. I have a script that allows the player to pick up, move and drop an object & my idea is to notify the player that the cube is in the correct position through audio source triggers, this script is attached to an audio source with box collider:
using UnityEngine;
using System.Collections;
public class SoundTrigger : MonoBehaviour {
public AudioSource source;
public void Awake() {
source = GetComponent<AudioSource> ();
}
public void OnTriggerEnter (Collider other) {
source.Play ();
}
}
I was wondering if anyone could give me some pointers as to how I can do this? Using c# I have no idea how to read the language, very very new to programming. I'm assuming that a script needs to be attached to a "door" object (with animation) that requires all triggers to be "awake"/"true"/"active"? No idea how that would be written down into the code though.
Many thanks
Hey, for the opening of doors, I can recommend this basic script I created:
https://www.assetstore.unity3d.com/en/#!/content/38694
For the triggers, you could make it so that if a box is placed in a certain place (so ontriggerenter) a boolean is set to true, then in my script do something like this 'if(bool1==true & & bool2==true) { Open(); }
Your answer
Follow this Question
Related Questions
KeyCode not detected when OnTriggerStay = true 1 Answer
Question about triggers 2 Answers
Trying to make a Parkour Platformer! 0 Answers
Opening door script in C# 3 Answers