Teleporter

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Text replace - "<javascript>" to "<syntaxhighlight lang="javascript">")
m (Text replace - "</javascript>" to "</syntaxhighlight>")
 
Line 16: Line 16:
 
     col.transform.position = teleportTo.position;
 
     col.transform.position = teleportTo.position;
 
}
 
}
</javascript>
+
</syntaxhighlight>
  
 
== CSharp - Teleporter.cs ==
 
== CSharp - Teleporter.cs ==

Latest revision as of 20:53, 10 January 2012


This script works like the halo Teleporters, but you can shoot rockets in to it and it come out the other teleporter Have fun with it. BY Ryan Davis.

Simply add two objects to your scene. Place this script onto the object you wish to be the entrance teleporter (must have a collider attached). Then drag the object from the Hierarchy, which will be the exit, into the slot named "teleportTo" in the entrances inspector, and voila.

[edit] Javascript - Teleporter.js

var teleportTo : Transform;
 
function OnCollisionEnter (col : Collision) {
    col.transform.position = teleportTo.position;	
}

[edit] CSharp - Teleporter.cs

using UnityEngine;
 
public class Teleporter : MonoBehaviour
{
    Transform teleportTo;
 
    void OnCollisionEnter (col : Collision) {
        col.transform.position = teleportTo.position;	
    }
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox