Setting a Global transform.position
Hey,
I'm pretty new to unity and am working on a simple way to walk through a "checkpoint" and anytime you can press a key and teleport back to that "checkpoint", but I've gotten stuck here's what I have so far.
SetCheckpoint.js
#pragma strict
static var TelePosition : Transform;
function Update () {
if (Input.GetKeyDown(KeyCode.F)) {
print("Teleporting....");
transform.position = TelePosition.position;
transform.rotation = TelePosition.rotation;
}
}
------------------------------------------------------------------------------------------------
CheckpointChange.js!
#pragma strict
function OnTriggerEnter (other : Collider) {
print("First");
CheckpointChange.TelePosition.position = Vector3(0,20,-4.2);
}
and here are the two errors I'm getting from first entering the box Collider and then attempting to teleport.
Your answer
Follow this Question
Related Questions
Vector3 is not receiving enough arguments from a another script that gives out transform.position. 1 Answer
[C#] [2D] Not changing positions correctly 1 Answer
How to correct the scale when using Transform.TransformPoint 2 Answers
Unity 3D interface says my button has a rectTransform C# script says otherwise 0 Answers
How to attach an object to another object so that moving one moves the other 0 Answers