“Unity 2d Looka TT Mouse” Kode Jawaban

Unity 2d Looka TT Mouse

void Update() {
     Vector3 dir = Input.mousePosition - Camera.main.WorldToScreenPoint(transform.position);
     float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
     transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
Outstanding Ocelot

2D Lihat Unity

//Look at 2D job using the unity jobs system
struct LookAtJob : IJobParallelForTransform
{
    public NativeArray<Vector2> targetPositions;
    public void Execute(int index, TransformAccess transform)
    {
        Vector2 dir = targetPositions[index] - (Vector2)transform.position;
        float angle = math.degrees(math.atan2(dir.y, dir.x));
        transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
    }
}
Sam Kessler

Jawaban yang mirip dengan “Unity 2d Looka TT Mouse”

Pertanyaan yang mirip dengan “Unity 2d Looka TT Mouse”

Lebih banyak jawaban terkait untuk “Unity 2d Looka TT Mouse” di C#

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya