- Home /
Question by
PavolM · Mar 07, 2012 at 11:46 PM ·
ontriggerenterstatic
OnTriggerEnter Problem
Hello Can anoyne help me solve this problem ? I have two simple scripts
What i want to do its, First Chcek if Player is In trigger position (and set var distance=true) and if is control animation of an object wih alt & ctrl if not do nothing( on exitin trigger set distance=false) ... i am using static variabile to acces it from other script
when im not using the "if ( Trigger2.Distance == "true")" script animation work fine i can controll it but with script i cant i have rigid body attached and also tagged player(even i think it dont need to be done in these case) name of script is correctly writed and trigger is marked on. Can anoyne help me ? thanks :)
first :
function Start () {
animation.wrapMode = WrapMode.Loop;
}
function Update () {
if ( Trigger2.Distance == "true")
{
if (Input.GetButtonDown ("Fire2")){
animation.CrossFade ("testtest1");
}
if (Input.GetButtonDown ("Fire1"))
{
animation.Stop();
}
}
}
second
static var Distance = false;
function OnTriggerEnter (other : Collider) {
Distance = true ;
}
function OnTriggerExit (other : Collider) {
Distance = false ;
}
)
Comment