Hey all,
I've set up a simple teleport script... which is working just great, save for one thing. The player is getting stuck in an infinite loop between the two teleports. To fight this, I would like to slightly throw the player out of the destination teleport. Which commands do I need to utilize? Thanks in advance, here's my code so far:
//Defining Variables
var destination : Transform;
var TeleportAudio: AudioClip;
//Player Enters Trigger
function OnTriggerEnter(other : Collider) {
//Play Teleport Audio
if (TeleportAudio)
AudioSource.PlayClipAtPoint(TeleportAudio, transform.position);
if (other.tag == "Player") {
//Transport Player to Pre Defined Destination
var startPosition = other.transform.position;
other.transform.position = destination.position;
var moveDelta = other.transform.position - startPosition;
//Move camera with player so it doesnt go wildly through the air
Camera.main.transform.position += moveDelta;
}
}
Hmmm.. thats not a bad plan actually. I'm fairly new to code, exactly how and were would I augment the players distance to the destination? Thanks!
– anon21113840NM... worked flawlessly, thanks!
– anon21113840