C
C#7mo ago
Britess

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;
2 Replies
Buddy
Buddy7mo ago
$code
MODiX
MODiX7mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
Want results from more Discord servers?
Add your server