- Home /
Animation Event for Mecanim
I figured out that I can use animation events for my mecanim character.
Well the problem is that I've made an event, but I don't have any idea how to use it in JavaScript.
I made at time 0.17 a function called "TakeOver"
And a float set up to "1"
And in my JavaScript, I used this
var Weapon : GameObject;
var Spine : GameObject;
var Hand : GameObject;
function TakeOver ()
{
if (TakeOver == 1)
{
Weapon.transform.parent = Hand.transform;
}
else
{
Weapon.transform.parent = Spine.transform;
}
}
But this is not working. Someone who can help me out with this problem? (I'm nearly driving crazy)
Thanks in advance!
Comment
Your function needs to have a float as a parameter in order to receive it from the event. Then the if should check if that parameter is equals to 1.
Best Answer
Answer by raulrsd · Mar 16, 2015 at 12:59 AM
Try this code:
function TakeOver (myFloat : float) {
if (myFloat == 1.0)
{
Weapon.transform.parent = Hand.transform;
}
else
{
Weapon.transform.parent = Spine.transform;
}
}
You're GREAT!! Thank you!!!! IT WOR$$anonymous$$S PERFECT