Skip to content

Instantly share code, notes, and snippets.

@xhan
Created May 6, 2010 17:06
Show Gist options
  • Save xhan/392396 to your computer and use it in GitHub Desktop.
Save xhan/392396 to your computer and use it in GitHub Desktop.
2 triggers' relationship -> unity3d
public enum TriggerState
{
Init,
Running,
Finished
}
public class MixerTriggerScript : MonoBehaviour {
public PieJuiceTriggerScript anotherTrigger;
public TriggerState state = TriggerState.Init;
bool bridgeCanPass = false;
public AnotherTriggerFinished()
{
// check the condition that this trigger finished first.
if(state == TriggerState.finished)
SlowAnimation();
}
void OnTriggerEnter(Collider col)
{
//animations and other stuffs
// check the condition that another trigger finished first.
if(anotherTrigger.state == TriggerState.finished) SlowAnimation();
else FastAnimation();
}
void FastAnimation()
{
}
void SlowAnimation()
{
bridgeCanPass = true;
}
}
public class PieJuiceTriggerScript : MonoBehaviour {
public MixerTriggerScript anotherTrigger;
public TriggerState state = TriggerState.Init;
void OnTriggerEnter(Collider col)
{
//animations and other stuffs
anotherTrigger.AnotherTriggerFinished();
}
}
/**********************************
* and at the Mixer object's script
* OnTriggerEnter - method
* check "MixerTriggerScript.bridgeCanPass" value , then kill character or not.
**********************************/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment