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

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

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:

http://unity3d.com/support/documentation/ScriptReference/Application.LoadLevel.html?from=MonoBehaviour

and this one:

http://unity3d.com/support/documentation/ScriptReference/Object.DontDestroyOnLoad.html?from=Application

I think that will do it !

Thanks by the way.

Franois

i thinked you translated the fps controller but ok, maybe change the scene like main menu -> start game or something like that

best regards

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;
        }
    }
}

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