So I want the object “TestEnemyCharacter” looking at my character as soon as a collision is triggered. However, whatever method I use to do it, the object always looks at a wrong direction that seems to be completely random. The object is also rotated, but I tried it without and it didnt change anything. I also think the properties of the collider that triggers the method doesnt play any role since im not turning the collider, but the object.
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player")
{
var target = GameObject.Find("Character");
GameObject.Find("TestEnemyCharacter").transform.LookAt(new Vector3(-target.transform.position.x, transform.position.y, -target.transform.position.z));
}
}
thank you for the help!