Question by
SirOrange · Feb 17, 2017 at 10:14 PM ·
animationanimatoranimator controlleranimationclipanimation editor
Animation Constantly Playing?
I have set up the animator and all of the code, but the animation keeps looping? Help, I really can't figure it out.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cHOPdOWNtHIStREE : MonoBehaviour {
public int Treelives;
public Animator _anim;
// Use this for initialization
void Start () {
Treelives = 10;
_anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown (0)) {
_anim.Play ("Chop", -1, 0f);
}
}
void OnTriggerEnter(Collider other){
if (other.CompareTag ("Tree")) {
if (Input.GetMouseButtonDown (0)) {
Treelives -= 2;
if(Treelives == 0){
Destroy(other.gameObject);
}
}
}
}
void OnTriggerExit(Collider other){
if (other.CompareTag ("Tree")) {
Treelives = 10;
}
}
}
Comment
Best Answer
Answer by toddisarockstar · Feb 19, 2017 at 08:31 PM
in the inspector, in the import settings of the model/animation. uncheck the box that says "Loop".