- Home /
Teleport when clicking a button
Hi everyone !
Here is my problem :)
I want to setup a bunch of buttons on my map. Each triggered buttons will teleport my player (FPS style) into different areas of the map. How can I setup that (I'm a beginner in coding, but understand the fonctions)
Thanks !
Franois
Answer by orange · Feb 21, 2011 at 03:35 PM
hi,
i hope my idea will help you.
i would try to get the collision event, before you should tagging your trigger with a new tag. Then i think its possible to get the tag while collide and then you can teleport you fps the the defined position.
i hope it helps you
best regars
Answer by Franois · Feb 21, 2011 at 03:51 PM
Actually, I can do something like loading a different map to that. Doesn't to be in the actual map (you cannot navigate between them).
I found those exemples:
and this one:
I think that will do it !
Thanks by the way.
Franois
Answer by orange · Feb 21, 2011 at 04:03 PM
i thinked you translated the fps controller but ok, maybe change the scene like main menu -> start game or something like that
best regards
Answer by Nynex71 · Feb 21, 2011 at 04:56 PM
Attach this to your player... This is written in c# so if you dont know it and are used to javascripting i apologize but here it is and its quite easy to understand so you should be able to easily make many different teleporting points. I may edit this later on if you comment back asking for this to be changed to make it more suitable for you.
using UnityEngine; using System.Collections;
public class Teleport : MonoBehaviour {
public Transform Teleport1;
// Update is called once per frame
void Update () {
}
void OnGUI() {
if(GUI.Button(new Rect(10, 50, 75, 25), "Teleport1")) {
transform.position = Teleport1.position;
}
}
}
Create an empty game object... rename it to teleport1 or something place it where you want to teleport to and than drag it onto the variable... Debug or Export your game (i recommend debugging) and try it out...
bro, do u have any idea for the script (above) to gravity up the FPS and fly to the destination (Teleport1)....i mean the FPS can do this at any coordinate..
Answer by Franois · Feb 24, 2011 at 01:00 PM
Ok, thanks !
I will try that and see if I've got any problems... (well, I don't know why, but I'm pretty sure I will have problems !)
Cheers, Franois
for the heck of it...there is a button called "add new comment"...
what do we have to do, make that button ten times bigger and flash in red?