- Home /
Question by
RotatingCelery · May 18, 2020 at 09:04 PM ·
animationscripting problemloop
Is there a way to turn off an animation looping in a script?
I want an animation to loop until button is lifted. This is my code: using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Rocket_Fly : MonoBehaviour
{ public float flyVelocity = 10f; public Animator animator;
void Start()
{
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Mouse0))
{
animator.SetBool("isClicked", true);
}
if (Input.GetKey(KeyCode.Mouse0))
{
GetComponent<Rigidbody2D>().AddForce(new Vector2(0, flyVelocity) * Time.deltaTime, ForceMode2D.Impulse);
animator.SetBool("isClicking", true);
}
if (Input.GetKeyUp(KeyCode.Mouse0))
{
animator.SetBool("isClicking", false);
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612234653im_/https://answers.unity.com/themes/thub/images/avi.jpg)