system
1
I want my Enemy to teleport behind me when i look at him, so it’s like an ambush or something else.
I tried to “mirror” my vector3 with the FirstPersonController as center, but it didn’t worked. Does anyone got an idea how to do this?
Sure:
//Get the vector from the player to the enemy
var currentDirection = (enemy.transform.position - player.transform.position);
//Take it away from the player's position
enemy.transform.position = player.transform.position - currentDirection.normalized * teleportDistance;
You could also use player.transform.forward instead of the currentDirection stuff and then it would be directly behind the player.