- Home /
trouble with teleportation script c#
Hello, i'm trying to make a teleportation script in unity with c# i have already made it so when they go through the teleport they end up at a different teleport with a sound i was wondering how i would make it so when you go through the teleport you end up just in front of the teleport not on it.
heres the code that teleport's me:
IEnumerator OnTriggerEnter(Collider other) {
if(other.tag == ("teleport 1")) {
audio.PlayOneShot(teleportSound);
yield return new WaitForSeconds(0.8f);
transform.position = SpawnPoint1.transform.position;
yield return new WaitForSeconds(1.5f);
Any help will be appreciated.
Answer by loopyllama · Apr 25, 2011 at 01:37 PM
float amount = 10.0F;
transform.position = SpawnPoint1.transform.position + SpawnPoint1.transform.forward * amount;
depending on the orientation of your SpawnPoint, you may have to throw a negative in there or do a .right instead of .forward
thankyou my fix was to deactivate the gameobject for a certain amount of time.
Answer by Trizza · Jan 12, 2012 at 07:06 AM
hey guys i need help 2 this is all i have for a teleport C# script please help me
using UnityEngine; using System.Collections;
public class teleport : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
Bwahaha, nice wording, it almost doesn't look like you just pasted an empty $$anonymous$$onoBehaviour. I knew this one was going to come up sooner or later, but leaving the default comments in is unexpected, genius!
Answer by Trizza · Jan 18, 2012 at 06:42 AM
yer its jst what comes up iv tried so many vids on youtube and copyed but it still neva works can you help me out
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Touch teleport script isnt working 2 Answers
Teleport the player from A to B 2 Answers
C# Instant Teleport Script 1 Answer
how to teleport a character 2 Answers