Britess
Britess
CC#
Created by Britess on 4/26/2024 in #help
can someone help me ?, Im doing a arrow that points to a enemy position based on the player position
Vector3 FirstPoint = (Player.position - transform.position).normalized; // Direção inicial do objeto
Vector3 LastPoint = (Inimigo.position - transform.position).normalized; // Direção final do objeto

float angle = Vector3.Angle(FirstPoint, LastPoint);

Quaternion PlayerRotation = Player.rotation;
float KartYrotation = Player.eulerAngles.y;
if (KartYrotation > 180f)
{
KartYrotation -= 360f;
}
Quaternion rightrotation = Quaternion.Euler(0f, 0f, angle - KartYrotation);

transform.rotation = rightrotation;
Vector3 FirstPoint = (Player.position - transform.position).normalized; // Direção inicial do objeto
Vector3 LastPoint = (Inimigo.position - transform.position).normalized; // Direção final do objeto

float angle = Vector3.Angle(FirstPoint, LastPoint);

Quaternion PlayerRotation = Player.rotation;
float KartYrotation = Player.eulerAngles.y;
if (KartYrotation > 180f)
{
KartYrotation -= 360f;
}
Quaternion rightrotation = Quaternion.Euler(0f, 0f, angle - KartYrotation);

transform.rotation = rightrotation;
3 replies