Created
May 6, 2010 17:06
-
-
Save xhan/392396 to your computer and use it in GitHub Desktop.
2 triggers' relationship -> unity3d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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