- Home /
Need Help with a play Animation script.
Hey guys , I have made a script that should and animation on an object "B after I enter the trigger zone of object "A" and press E button in it. So help me guys , I have no idea why It's not working. And thank you for your time =)
var target : GameObject;
var yourVar = false;
var triggered = false;
var Trigger1 : AudioClip;
function OnTriggerEnter(other : Collider)
{
yourVar = true;
}
function OnTriggerExit(other : Collider)
{
yourVar = false;
}
function Update()
{
if(Input.GetKeyDown(KeyCode.En) && !yourVar)//if yourVar is true
{
audio.PlayOneShot(Trigger1);
triggered = true;
target.animation.Play("keyAnim");
yourVar = false;
}
}
Answer by Xtro · Aug 16, 2013 at 03:40 PM
do you see an error?
is "keyAnim" animation registered in the animation controller?
did you debug the trigger events to see if they are fired at all ?
did you test by setting the yourVar true by default to see if it's working that way?
as you can see, there are too many unknowns here. you should be able to test your code and supply some info about it. Otherwise, you can't develop a game or even any software.
additionally, in the if block... !yourVar isn't equal to True. Make sure your logic is correct there.
Everything is correct and it was working perfect before I've added the sound part ...
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Need help with a shop script.. :/ 1 Answer
Weapon Customizations Script Problem 0 Answers
Whats wrong with this 2 Answers
DamageScript 1 Answer