So, i’m trying to get a direction, but somehow it’s in the completely wrong position, seeming to be endlessly far away.
My gameobjects also show up in the sky, but i think that is just my other cameras seeing them, because i couldn’t find any gameobjects there, yet the target direction seems to point that way.
I hope you can shed some light on my situation.
By looking at this piece of code and a picture it might make more sense.
Here are the variables
GameObject current_enemy;
self = transform.position + new Vector3(0f, 1f, 0f);
float angleToEnemy;
Vector3 targetDirection;
This is where i get the direction to the target.
void CheckIfFacingEnemy() {
targetDirection = self + current_enemy.transform.position;
angleToEnemy = Vector3.Angle(targetDirection, transform.forward);
if(angleToEnemy < 40) { _facingEnemy = true; }
else { _facingEnemy = false; }
}
and heres gizmos
void OnDrawGizmosSelected() {
Gizmos.color = Color.red;
Gizmos.DrawRay(transform.position + new Vector3(0, 1, 0), targetDirection);
Gizmos.DrawSphere(current_enemy.transform.position, 2);
}
and this picture show that the current enemy is at the right place on the ground, but also showing up in the sky, where it seems to point…
Keep in mind that i can’t find any gameobjects in the sky where you can see the reflections.
The only thing i know is that my confusion level is way over 9000.
If i didn’t provide enough information, please let me know.
