private Rigidbody rb;
public Animator anim;
public float timer;
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody>();
anim = GetComponent <Animator>();
anim.SetBool ("Animate", true);
I have an animation in my animation controller.
As you can see I put it into Start().
Why does it keep playing infinitelly? I thought it should stop after the very first loop (given that it’s in Start).
What’s the quickest way to make it stop after the first playthrough?
Thanks.
check your animation is having loop time set to true or not ?
I'm sorry to hear that. At the moment I'm not around a Computer. I'll create a test scene once I got home. In the next couple of hours. Have you tried hexagonius solution? eg.: Destroy(this.gameObject, sound1.Length);
A trigger parameter is a bool parameter that gets reset to false when it has been used in a transition. For state machines with multiple layers, the trigger will only get reset once all layers have been evaluated, so that the layers can synchronize their transitions on the same parameter.
You can set trigger variable using SetTrigger() method. So your Start() method will look like:
However if you stick to use Bool. Then you have to reset Animate to false in some other method which is called just after Start(). Simple technique is using Invoke() method in which set Animate to false. For example:
yeah the collision happens. but the object only gets destroyed, if I have the code like that: function OnCollisionEnter (col : Collision) { Debug.Log("Collision Enter"); Destroy(this.gameObject); sound1.Play(); GetComponent(ScoreScript).score += kunai; }
check your animation is having loop time set to true or not ?
– Ekta-Mehta-D