Hello There I am still quite new with scripting. I know the basics of javascript but sadly i dont know yet so many scripts so i would need some help on this one. Now i am planning to create a "Teleporter" kind of script that when I (First Person Controller) Collides with it will teleport me to Vector3 (x,y,z) Now i have done a script that works and teleports me ( my death script when i fall on terrain i "respawn/teleport" back to beginning). The problem is that this script works with all objects that have a collider. Here it is Code (JavaScript): #pragma strict function OnTriggerEnter (other : Collider) { transform.position = Vector3(7.619988,1.81378,4.6828); } function Update () { } So what i need is either if i collide with the teleporter it will position me. Or i need to rescript my death script so it only affects for 1 specific colider and not with all coliders. Any help is appreciated
Add a tag on your collider to identify it and compare the tag on the collider in your OnTRiggerEnter(). If the tag == "Player" then you can teleport back the player.
Hey man sorry i forgot to write that i have solved the problem. I will add the script soon so others can see it too
Here Code (JavaScript): #pragma strict var TeleportMe = String; TeleportMe = CharacterController; function OnTriggerEnter (other : Collider){if(other.gameObject.name == "Name") // <-- Name comes here if (TeleportMe == CharacterController) { transform.position = Vector3(0,0,0);// <-- Spawn Position comes here } }