How to Teleport in Unity | Unity Tutorial

Поділитися
Вставка
  • Опубліковано 22 січ 2025

КОМЕНТАРІ • 51

  • @DJdawwg-gi1ik
    @DJdawwg-gi1ik 10 місяців тому

    Finally A simple but yet working Mechanic

  • @MadCyantist
    @MadCyantist Рік тому +2

    exactly what I needed and so so so simple thank you!

  • @XxTheSabertoothxX
    @XxTheSabertoothxX 9 місяців тому

    This tutorial helped me so much. Only issue I encountered was due to the fact that I was using a custom player controller instead of Rigidbody. For those in a similar situation:
    You can use an IEnumerator block which adds a short delay before you transport which allows you to use a custom controller without having to deactivate the player controller. This is what I used:
    IEnumerator Teleport() // this sets a delay for the teleport between each line of code so that it doesnt execute too fast.
    {
    yield return null; // you could set this for milliseconds/seconds with "WaitForSeconds", but returning null skips one frame.
    player.position = destination.position;
    yield return null;
    }
    Then I will call in the collider if statement like so:
    void OnTriggerEnter(Collider other)
    {
    if(other.CompareTag("Player"))
    {
    StartCoroutine("Teleport");
    }
    }

  • @RealCreacher
    @RealCreacher Рік тому +1

    how do you make it where your rigiged body doest go crazy when I hit a wall

  • @TSMAstroPug
    @TSMAstroPug 6 місяців тому

    I wrote the script out but the Destination options and stuff dont show

  • @hilariousroom3181
    @hilariousroom3181 Рік тому

    How do you press a certain button while looking at a certain object to teleport somewhere?

  • @Glados44
    @Glados44 7 місяців тому

    You are awesome as always. Just to the point.

  • @alexx4450
    @alexx4450 6 місяців тому +3

    Great tutorial, thanks! If you have a problem with getting it to work with different character controller, try this:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class TeleportPlayer : MonoBehaviour
    {
    public Transform destination;
    private void OnTriggerEnter(Collider other)
    {
    if (other.CompareTag("Player"))
    {
    // Teleport the player to the destination
    other.transform.position = destination.position;
    }
    }
    }
    This way you could do it without referencing the object from the scenes such as while using clones in menager.

  • @FatChang
    @FatChang 2 роки тому +2

    I’m pretty sure I did everything right but it’s not teleporting when my player comes in contact with the box collider

  • @ays.fennix
    @ays.fennix 2 роки тому +1

    I get an error message in the console saying that "player" is not defined, how can I fix this?

    • @mikdailyreview5277
      @mikdailyreview5277 2 роки тому +2

      add player tag to your player controller / watch Brackeys

    • @ays.fennix
      @ays.fennix 2 роки тому

      @@mikdailyreview5277 thank u

  • @zmjjkk1
    @zmjjkk1 Рік тому

    I'm moving with an XR rig called 'XR Origin (XR Rig)' instead of a 'Player' model, with a character controller underneath it. Would my script in the "comparetag" change? Any help would be AMAZING

  • @AgentaDark
    @AgentaDark 2 роки тому +1

    hi when i try to add the script to my cube it says
    cant add script beacuse class cannot be found make sure there are no compile errors and that the file name and class name match

    • @mikdailyreview5277
      @mikdailyreview5277 2 роки тому +1

      you changed the script name in the editor / make sure the scripts name is the same in both visual studios and the unity editor

    • @AgentaDark
      @AgentaDark 2 роки тому +1

      @@mikdailyreview5277 I quit unity 3 months ago I'm a full time gamer now and I'm trying to become famous on youtube

  • @Magah051
    @Magah051 3 місяці тому

    Great job man! Thanks!

  • @TeachMeSam
    @TeachMeSam Рік тому

    Works perfectly, thank you very much.

  • @bijanroy4122
    @bijanroy4122 6 місяців тому

    it not work with ready player me avatar

  • @Spaceyyy
    @Spaceyyy Рік тому

    Brilliant, thank you very much. Works perfectly.

  • @SlayziFuntime
    @SlayziFuntime Рік тому

    hello
    i wasnted to ask if "playerg" in the script should be changed to the name of the player gameobject in the project
    ?

  • @enfity
    @enfity 9 місяців тому

    thank you very much! this video helped me when I detected a teleportation bug in my VR game

    • @warittorn3206
      @warittorn3206 8 місяців тому

      Hello, I'm also doing a VR project for my college. I'm having a problem where the player can teleport to the destination, but grabbed objects will always drop to the ground. Does yours work with retaining grabbed object?

  • @dunderguy
    @dunderguy 2 роки тому +2

    Thanks this worked :)

  • @dertobbe1176
    @dertobbe1176 Рік тому

    Thx alot. I did another thing but setActive is the solution 👍
    Edot: im so happy right now. Rly thanks for thks 🙂

  • @coffeetea5915
    @coffeetea5915 6 місяців тому

    thanks! the ways to fix it helped too!

  • @aaronchipman4438
    @aaronchipman4438 Рік тому +2

    I found the video to be very useful. I would love to see more simple game mechanics like this.

  • @PatrickK-er6yu
    @PatrickK-er6yu 10 місяців тому

    thank you soo much it fixed a magor problem i had thanks!

  • @iambored_dev
    @iambored_dev Рік тому +1

    im so glad he is not a pycopath and uses dark mode

    • @Danxx408
      @Danxx408 7 місяців тому +1

      Bro wht

  • @zulfikarbasawal6549
    @zulfikarbasawal6549 Рік тому

    Thank you. its super effective

  • @Poiter0
    @Poiter0 Рік тому

    thank you, this was very helpful!

  • @Nxftqiue
    @Nxftqiue 2 місяці тому

    Simple thanks!

  • @PLCMusicMaker
    @PLCMusicMaker Рік тому

    Thank you for the great tutorial! What template did you use this? First Person? 3D URP? I tried to do your tutorial in a VR setup. I had an orb which I labled the receiver; it was a sphere with a sphere collider and a XR Origin rig which I tried to use as the player. I'm new to Unity so I'm sure I missed a lot of things. Anyhow, your solution is eloquent and simple, and I'm wondering where I went wrong. The script kept getting rejected.

  • @calvinchow5037
    @calvinchow5037 Рік тому

    very useful and easy to understand video

  • @mikdailyreview5277
    @mikdailyreview5277 2 роки тому +2

    Found it very helpful. Thanks so much.

  • @_MADSTER
    @_MADSTER 2 роки тому

    how to add player into unity?

  • @Unlit_coder
    @Unlit_coder 10 місяців тому +1

    not working ):

  • @wearwolf4202
    @wearwolf4202 Рік тому

    How do you wait longer? You know for an animation to finish before being able to move?

    • @Omogonix
      @Omogonix  Рік тому

      You would use a coroutine for that. I recommend looking up how to start coroutines and how to use "yield return new WaitForSeconds(Amount of seconds);"

  • @I_love_moto
    @I_love_moto Рік тому

    how do i get into the script

    • @Cactusking1
      @Cactusking1 Рік тому

      Right click your assets and click creat C# script or creat script and name it. Then your just nead to dubbel click the scrip and then it should open. if not you nead to download some thing like Visual Studios and code in there. Hop this helps

  • @konnyboii1020
    @konnyboii1020 3 роки тому +1

    BEST VID

  • @Clasher_7617
    @Clasher_7617 2 роки тому +2

    Thank you

  • @plastictrash6427
    @plastictrash6427 Рік тому

    great guide thx

  • @WIZBIWANG
    @WIZBIWANG 7 місяців тому

    nice

  • @itzKoolfy
    @itzKoolfy Рік тому

    THANKS