Ahmet Efe11
Decapat
- Katılım
- 18 Ağustos 2023
- Mesajlar
- 158
- Çözümler
- 1
Daha fazla
- Cinsiyet
- Erkek
Başlıkta belirttiğim gibi karakterin idle animasyonu çok güzel bir şekilde çalışırken run animasyonu çalışmıyor oyun duruyor.
using UnityEngine;
public class CharacterController2D : MonoBehaviour
{
public float runSpeed = 5f;
private Animator animator;
private Rigidbody2D rb;
void Start()
{
animator = GetComponent<Animator>();
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
float move = Input.GetAxis("Horizontal");
if (move != 0)
{
rb.velocity = new Vector2(move * runSpeed, rb.velocity.y);
animator.SetFloat("Speed", Mathf.Abs(move)); // Run threshold
}
else
{
animator.SetFloat("Speed", 0f); // Idle threshold
}
}
}
using UnityEngine;
public class CharacterController2D : MonoBehaviour
{
public float runSpeed = 5f;
private Animator animator;
private Rigidbody2D rb;
void Start()
{
animator = GetComponent<Animator>();
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
float move = Input.GetAxis("Horizontal");
if (move != 0)
{
rb.velocity = new Vector2(move * runSpeed, rb.velocity.y);
animator.SetFloat("Speed", Mathf.Abs(move)); // Run threshold
}
else
{
animator.SetFloat("Speed", 0f); // Idle threshold
}
}
}