Hello Unity3D.I have a question about teleporting?How can i make it that my character teleporting to an object but it teleports 5 feet behind the object?For example.Whenever i press my teleport key my character teleports to the object but it teleports right on top of the object.What i want is that,whenever i press my teleport key my character teleports 5 feet behind the object so that my character doesn’t get clamped up with the object.If anyone knows how i can do this?Can you please tell me how?
P.S Here is the script if anyone needs it.
var amount : float = 5;
var player : Transform;
var enemy : Transform;
function Update () {
var player = GameObject.FindWithTag("Player").transform;
var enemy = GameObject.FindWithTag("Dummy").transform;
if(Input.GetKeyDown("t")) {
animation.Play("Teleport");
Switch();
}
}
function Switch()
{
yield WaitForSeconds(.5);
player.transform.position = enemy.transform.position - enemy.transform.forward * amount;//change position to secondObject, whatever that is.
}
player.transform.position = enemy.transform.position - enemy.transform.forward * ammount
ammount is a float (distance)