“2D OLHE AS UNIDADE” Respostas de código

unidade 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

unidade olha 2d

Vector3 dir = target.position - transform.position;
 float angle = Mathf.Atan2(dir.y,dir.x) * Mathf.Rad2Deg;
 transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
Courageous Cowfish

2D OLHE AS UNIDADE

//this code will point the object to the mouse
Vector3 diff = Camera.main.ScreenToWorldPoint(Input.mousePosition) 
	- transform.position;
diff.Normalize();
 
float rot_z = Mathf.Atan2(diff.y, diff.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, 0f, rot_z - 90);
Daragard

2D OLHE AS UNIDADE

//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

Respostas semelhantes a “2D OLHE AS UNIDADE”

Perguntas semelhantes a “2D OLHE AS UNIDADE”

Mais respostas relacionadas para “2D OLHE AS UNIDADE” em C#

Procure respostas de código populares por idioma

Procurar outros idiomas de código