Unity'de karakterin gitiği yöne bakmaması

Ahmet Efe11

Picopat
Katılım
18 Ağustos 2023
Mesajlar
39
Daha fazla  
Cinsiyet
Erkek
Unity'de bir savaşçı oyunu yapıyorum ve karakterin gittiği yöne bakmasını istiyorum


Using jetbrains. Annotations;
Using System. Collections;
Using System. Collections. Generic;
Using unityeditor. Tilemaps;
Using unityengine;

Public class run: Monobehaviour.
{
Public float movespeed;
Private animator anim;
Private rigidbody2D RB;
Float movehorizontal;
Public bool faceinright;

Void Start()
{
Movespeed = 5;
Movehorizontal = ınput. Getaxis("horizontal");
Anim = GetComponent<Animator>();
RB = GetComponent<Rigidbody2D>();

}

Void Update()
{
charactermovement();
characterAnimation();
}
Void charactermovement()
{
Movehorizontal = ınput. Getaxis("horizontal");
RB. Velocity = New Vector2(movehorizontal * movespeed, RB. Velocity. Y);
}
Void characterAnimation()
{
İf (movehorizontal>0)
{
Anim. Setbool("running", true);
}

İf (movehorizontal < 1)
{
Anim. Setbool("running", false);
}

İf (movehorizontal < 0)
{
Anim. Setbool("running", true);
}
İf (faceinright = false && movehorizontal > 1)
{
characterFlip();
}
İf (faceinright = true && movehorizontal < 0)
{
characterFlip();
}

Void characterFlip()
{
Faceinright =!faceinright;
Vector3 scaler = transform. Localscale;
Scaler. X *= -1;
Transform. Localscale = scaler;

}
Bu kodları yazdım ama çalışmadı değişik bir bug oldu nasıl düzeltebilirim?
 

Yeni konular

Geri
Yukarı