Teleporter

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Applied code formatting and fixed indentation to spaces.)
m (Text replace - "</javascript>" to "</syntaxhighlight>")
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
[[Category: MonoBehaviour]]
 +
[[Category: C Sharp]]
 +
[[Category: JavaScript]]
 +
[[Category: ReallySimpleScripts]]
 +
 
This script works like the halo Teleporters, but you can shoot rockets in to it and it come out the other teleporter
 
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.
 
Have fun with it. BY Ryan Davis.
  
== Teleporter.js ==
+
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.
<javascript>
+
 
 +
== Javascript - Teleporter.js ==
 +
<syntaxhighlight lang="javascript">
 
var teleportTo : Transform;
 
var teleportTo : Transform;
function OnCollisionEnter (col : Collider) {
+
 
 +
function OnCollisionEnter (col : Collision) {
 
     col.transform.position = teleportTo.position;
 
     col.transform.position = teleportTo.position;
}</javascript>
+
}
 +
</syntaxhighlight>
 +
 
 +
== CSharp - Teleporter.cs ==
 +
<syntaxhighlight lang="csharp">
 +
using UnityEngine;
 +
 
 +
public class Teleporter : MonoBehaviour
 +
{
 +
    Transform teleportTo;
 +
 
 +
    void OnCollisionEnter (col : Collision) {
 +
        col.transform.position = teleportTo.position;
 +
    }
 +
}
 +
</syntaxhighlight>

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