Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

199
Vistas
Running animation loop is weird (see video) (c#)

Whenever my character runs, it has this weird loop, I asked other people and I checked tutorials. I could not find it. See video for more information.

Video:

Video

Code:

public GameObject thePlayer;
public bool isRunning;
public float horizontalMove;
public float verticalMove;

void Update () {
    if (Input.GetButton("Horizontal") || Input.GetButton("Vertical"))
    {
        thePlayer.GetComponent<Animation>().Play("Run");
        horizontalMove = Input.GetAxis("Horizontal") * Time.deltaTime * 150;
        verticalMove = Input.GetAxis("Vertical") * Time.deltaTime * 8;
        isRunning = true;
        transform.Rotate(0, horizontalMove, 0);
        transform.Translate(0, 0, verticalMove);
    }
    else
    {
        thePlayer.GetComponent<Animation>().Play("Idle");
        isRunning = false;
    }
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The reason for that could be that you get the component each frame instead of just getting it once. That could cause problems. Try doing this:

void Start()
{
     anim = thePlayer.GetComponent<Animator>();
}

and then play it in the Update function like this:

anim.Play("Run");

and then in your else statement, do the same with Idle just to make sure:

anim.Play("Idle");
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda