- Home /
 
 
               Question by 
               $$anonymous$$ · Mar 25, 2013 at 12:43 PM · 
                vector3teleportbehind  
              
 
              Mirror a Vector3
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?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by whydoidoit · Mar 25, 2013 at 12:46 PM
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.
that one worked for me. thank you for the quick response :)
Your answer
 
             Follow this Question
Related Questions
How to teleport gameobject (instantly change transform.position) 3 Answers
Player slows down every time they are movies? 0 Answers
Spawning System 1 Answer
GameObject.FindGameObjectWithTag is not working 2 Answers
Teleporting when interacting with object 0 Answers