- Home /
Get a UserTrigger in Javascript - Eg for SmoothMoves
How the heck do you get a UserTrigger in Javascript ?
Anyone know? Thanks!
For the record, here is the exact Javascript to do this in SmoothMoves.
Note it is very very important to remember to call newTest.Play("one") .... do not accidentally call newTest.animation.Play("one") which is what you would be familiar with typing as a Unity developer. Of course, the latter will just call the "normal" animation of the object, and everything will go to hell, you very much want to call the actual SmoothMoves animation of the object!!
Here is the exact JS to register both SmoothMoves animations and SmoothMoves user-triggers. Thanks again Bérenger Mantoue !!!!!!
#pragma strict
import SmoothMoves;
private var newTest:SmoothMoves.BoneAnimation;
public function testeCollider(uTE:SmoothMoves.ColliderTriggerEvent):void
{ Debug.Log("the collider fired"); }
public function testeUserTrigger(uTE:SmoothMoves.UserTriggerEvent):void
{ Debug.Log("the user-trigger fired"); }
function Start ()
{
newTest = GameObject.Find("newTest").GetComponent(SmoothMoves.BoneAnimation);
newTest.RegisterColliderTriggerDelegate(this.testeCollider);
newTest.RegisterUserTriggerDelegate(this.testeUserTrigger);
Debug.Log("I did register everything.");
}
function OnGUI()
{
if (GUI.Button (Rect (300,200,100,20), "play one"))
newTest.Play("one");
if (GUI.Button (Rect (420,200,100,20), "play two"))
newTest.Play("two");
}
I don't see how it would be any different with javascript here, except obvious keywords (public void => function etc). Have you tried it ?
Actually I don't even see that UserTrigger button on my animation window,is that a pro feature?
It's specific to smooth moves, a package from the asset store for 2D animation. I had never heard of it until today though.
Answer by Berenger · May 03, 2012 at 08:37 PM
Just to take it out of the unanswered :
The functions of registration are members of Smooth Moves' class BoneAnimation, thus available in both javascript and C#.
one of the most magnificent answers ever seen on this forum ! thanks :)