How To Make 2D Teleporters In Unity

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024
  • Learn how to make 2D teleporters in Unity!
    Source code: gist.github.co...
    SOCIAL
    Discord: / discord
    itch.io: bendux.itch.io/
    Twitter: / bendux_studios
    SUPPORT
    Buy Me a Coffee: www.buymeacoff...
    MUSIC
    Brain Trust by Wayne Jones
    Link: / @waynejonesmusic
    Shades of Spring by Kevin MacLeod
    Link: incompetech.fi...
    License: filmmusic.io/s...

Комментарии • 120

  • @laszlomezei9046
    @laszlomezei9046 Год назад

    You probably wont see it now, but I would like to thank you either. Good job m8! 😁

  • @PhantomJH
    @PhantomJH 3 года назад +19

    Thank you for this video, it is really helpful. The way you explain things is very clear and easy to follow along.

  • @dabrnii7854
    @dabrnii7854 2 месяца назад +1

    thanks man great video but i have only one issue when i teleport some methods that works before teleportation do not work after i do teleport like grabbing objects can you help me on this one plz

  • @alexd406
    @alexd406 Год назад +3

    UR THE BEST MAN TO EVER LIVE

  • @SMT-ks8yp
    @SMT-ks8yp 3 года назад +2

    Wait, do OnTrigger methods detect contacts with other triggers and not only whatever touches tis object's trigger-collider?

  • @nqzy
    @nqzy Год назад +2

    many thanks, helping me not fail my gaming design assignment

  • @kitsun3246
    @kitsun3246 3 года назад +5

    super useful, thanks!

  • @Razi1
    @Razi1 2 года назад +1

    can i have some help ? i get an error: NullReferenceException: Object reference not set to an instance of an object

    • @bendux
      @bendux  2 года назад

      Would you like to show me your code on Discord?

  • @mohamedalmatter9073
    @mohamedalmatter9073 2 года назад +1

    I have a small problem but I cant fix it, when is use the teleport the player change the position of z axis to the position of the teleport. and thanks for this helpful video

    • @bendux
      @bendux  2 года назад +3

      Make sure that your player and the teleporters are in the same position on the z-axis.

  • @PrimalEffect2
    @PrimalEffect2 Год назад +1

    Bendux I like your videos, can you make sprite animation tutorials?

    • @bendux
      @bendux  Год назад

      I definitely want to make a video about animations in the future.

  • @KazukiP
    @KazukiP 2 года назад +1

    I'm getting this error:
    Assets\Assets\PlayTeleport.cs(14,65): error CS0246: The type or namespace name 'Teleporter' could not be found (are you missing a using directive or an assembly reference?)
    What exactly am I doing wrong here?

    • @bendux
      @bendux  2 года назад

      Would you like to show me your code on Discord?

    • @KazukiP
      @KazukiP 2 года назад +1

      @@bendux Yo I would seriously appreciate that! Edit: I got it all sorted thanks to some help in your discord so don't worry! It was actually something very simple lol, I had named my other file "Teleportation" instead of "Teleporter" hahhaah

    • @user-xt3pd4oy3s
      @user-xt3pd4oy3s Год назад

      @@KazukiP This is 1 year after the post so you might not see this but, I HAD THE SAME PROBLEM! 🤣 Thank you so much, your comment actually solved my error.

  • @Danny-tl1sb
    @Danny-tl1sb Год назад +1

    What do i need to click to teleport?

    • @bendux
      @bendux  Год назад +1

      docs.unity3d.com/ScriptReference/KeyCode.E.html

    • @Danny-tl1sb
      @Danny-tl1sb Год назад +1

      @@bendux thanks very much. Love your Tutorials.

  • @ltjohnno
    @ltjohnno 3 года назад +1

    Thx so much you just got your self another sub +like

  • @dylancurry5499
    @dylancurry5499 2 года назад +1

    OMG 666TH subscriber lol

  • @alviratulaha8618
    @alviratulaha8618 3 года назад +2

    Thanks for this tutorial! Can you make it so that when the player is teleporting, there is an animation an sound effects?

  • @antibanplay
    @antibanplay 3 года назад

    yo wasup that was useful but i need without key binding. for doodle clone. code work with key bind but soon as i deleted the key bind part it won't work (no errors) it's not triggering (trigger on)

    • @bendux
      @bendux  3 года назад

      Join our Discord server, and let's solve your problem together!

  • @mrmax5855
    @mrmax5855 Год назад

    hey it is me again, I fixed the other problem but now it says that the namespace teleporter could not be found, what do i do?

    • @bendux
      @bendux  Год назад

      Would you like to show me your code on Discord?

  • @sayginisbay2365
    @sayginisbay2365 Год назад

    hello, ı have one problem, when ı am teleported ı cant teleport again before going outside of my portal

    • @bendux
      @bendux  Год назад

      Would you like to show me your code on Discord?

  • @aeminkahraman
    @aeminkahraman 3 года назад +3

    Hey! Thank you for the tutorial. So how we make the teleport type 1 that you mentioned in your video :D I use a moving object and i want to teleport it as soon as it hits the target. I made remove one of the colliders from the teleporters but thats makes it only one way teleportation.

    • @bendux
      @bendux  3 года назад +2

      We have a solution for that on our Discord server. Feel free to join!

    • @aeminkahraman
      @aeminkahraman 3 года назад

      @@bendux I appreciate

    • @olegushakov5074
      @olegushakov5074 7 месяцев назад

      delete if (Input.GetKeyDown(KeyCode.E)) and connected {}s

  • @micol04
    @micol04 2 года назад +3

    Here's the code if you need it
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class PlayerTeleportation : MonoBehaviour
    {
    private GameObject currentTeleporter;
    // Start is called before the first frame update
    // Update is called once per frame
    void Update()
    {
    if (Input.GetKeyDown(KeyCode.E))
    {
    if (currentTeleporter != null)
    {
    transform.position = currentTeleporter.GetComponent().GetDestination().position;
    }
    }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
    if (collision.CompareTag("Teleporter"))
    {
    currentTeleporter = collision.gameObject;
    }
    }
    private void OnTriggerExit2D(Collider2D collision)
    {
    if (collision.CompareTag("Teleporter"))
    {
    if (collision.gameObject == currentTeleporter)
    {
    currentTeleporter = null;
    }
    }
    }
    }

  • @digbyeaston
    @digbyeaston 6 месяцев назад

    Thankyou verymuch, This was really helpful to my school game project im doing rightnow, ur the man.

  • @javiergonzaloandres-usal1725
    @javiergonzaloandres-usal1725 3 месяца назад

    Concise and helpful video, straight to the point. Kudos!

  • @KnowInDetails
    @KnowInDetails 3 года назад +1

    Thank you for this useful tutorial , can you please make a short video on integrating new unity ads scripting for rewaredvideo?

    • @bendux
      @bendux  3 года назад +1

      I've added it to my list. Thank you!

  • @bmo_0143
    @bmo_0143 2 года назад +1

    My character is disappearing when i use one of my teleporter. Can you help me?

    • @bendux
      @bendux  2 года назад +2

      It probably has something to do with the position of your teleporter on the z-axis. Does your player have a different position on the z-axis after teleporting?

    • @bmo_0143
      @bmo_0143 2 года назад

      @@bendux yes it goes from 0 to -1793
      what can i do?

    • @bendux
      @bendux  2 года назад

      @@bmo_0143 If possible, set the position of your teleporter on the z-axis to zero.

    • @bmo_0143
      @bmo_0143 2 года назад

      @@bendux Wow! thank you for the help i fix the z-axis and its working now!

  • @dzdraco19
    @dzdraco19 Год назад

    Hey why is it when I use the teleporter it sends me back to spawn?

    • @bendux
      @bendux  10 месяцев назад +1

      Make sure that the destination of each teleporter is assigned correctly.

    • @dzdraco19
      @dzdraco19 10 месяцев назад

      @@bendux ok

  • @snigames
    @snigames Год назад

    Ahhhhhhhhhhhh!!!!!!! Thank you very much!!!
    This will work perfectly for my bonus level!
    I joined your discord, I need to know how to change the scene using a portal. The portal is the end level, I need to press a button to activate it and take me to the next level; it also has the condition that the number of runes collected MUST be equal to 5. Otherwise it won't activate, instead send a message. The second part I can manage.
    It's the scene change that's the problem. Can you help me out? I've already asked the question on Discord. Thanks.

  • @aze2695
    @aze2695 3 года назад +1

    nice video, but how do i make a sprite randomly teleport every second. I really need that for my game.

    • @bendux
      @bendux  3 года назад +1

      The answer to your question goes beyond the scope of a RUclips comment, but I'd still like to help you. Join our Discord server, and let's solve your problem together!

    • @PrimalEffect2
      @PrimalEffect2 Год назад

      You can just search it on yt if you're still searching for an answer, search this "How to make sprite teleport every second/amount of time"

  • @axolotlagatsuma
    @axolotlagatsuma 10 месяцев назад

    Appreciate it man, I just made a game just by using your code thx. I added you in the credits I'll send you a link to it when it releases.

  • @indraprasathrau
    @indraprasathrau 3 года назад +1

    quick and simple.. Nice work.. and thanks!

  • @expertarc3861
    @expertarc3861 2 года назад +1

    I had a problem with an error saying that the namespace or name teleporter could not be found and that i might be missing a using directive or assembly reference. I know its something i did wrong but I've checked and i dont know whats wrong so i wondered if you have any tips. Btw these tutorials are really usefull

    • @bendux
      @bendux  2 года назад

      Join our Discord server, and let's solve your problem together!

    • @expertarc3861
      @expertarc3861 2 года назад

      Thanks!

    • @alistairlikesramen
      @alistairlikesramen 2 года назад

      @@expertarc3861 do you know how to fix it

    • @expertarc3861
      @expertarc3861 2 года назад

      Yes i was quite new then. but i have a greater understanding now but thanks anyway.

    • @ghmz_306
      @ghmz_306 Год назад

      What is the fix?

  • @FireGloves
    @FireGloves Год назад

    Something's not working, I went to Unity and it's showing error wherever i typed "CompareTag". help me, i've checked everything i could.

    • @bendux
      @bendux  Год назад

      What kind of error message do you get?

  • @decksengchia9659
    @decksengchia9659 2 года назад

    sir i got some problem here
    Assets\Script\Teleporter.cs(7,40): warning CS0649: Field 'Teleporter.destination' is never assigned to, and will always have its default value null.
    i don"t know what I doing wrong here

    • @bendux
      @bendux  2 года назад

      Would you like to show me your code on Discord?

  • @PaziaTV
    @PaziaTV Год назад

    I'm getting this error for the last piece of the puzzel.. "The type or namespace name 'currentTeleporter' could not be found (are you missing a using directive or an assembly reference?)"
    Any idea what I did wrong? :(

    • @bendux
      @bendux  Год назад

      Join our Discord server, and let's solve your problem together!

  • @nikita_5315
    @nikita_5315 Год назад

    Thank you! Really Good Chanel! Good!

  • @rbstudios7420
    @rbstudios7420 3 года назад

    WHY DOES NOT SCRIPTS WORK FOR ME IVE BEEN TRYING THIS STUFF FOR LIKE 5 HOURS AND NOTHING WORKS WTF IS HAPPENING!??!?!?!

    • @bendux
      @bendux  3 года назад

      Join our Discord server, and let's solve your problem together!

  • @alexeakins1
    @alexeakins1 Год назад

    you are amazing my man, thank you so much

  • @CNerdzik
    @CNerdzik 2 года назад

    I made everything the same but something didn't work. Maybe that's code error?

    • @bendux
      @bendux  2 года назад

      Would you like to show me your code on Discord?

  • @deryaburhanoglu7192
    @deryaburhanoglu7192 Год назад

    everything okay but where is the teleporter doors and how to add them teleporting funcionality
    ?

    • @bendux
      @bendux  Год назад

      What do you mean?

  • @poliswag404
    @poliswag404 Год назад

    This tutorial is vety however I am instrestad in making for example 4 teleporters meaing 2 sets of teleports working as yours are with no crossover , how could I go about making that in a more scalable way?

    • @bendux
      @bendux  Год назад

      You can create as many teleporters as you want.

  • @bogdansmolliansku4565
    @bogdansmolliansku4565 Год назад

    Thank you very much, you saved my day

  • @DemonkaiMugen
    @DemonkaiMugen 3 года назад +4

    Any chance that you will make a 2D tutorial for beginners how to create a crouch function for a 2D platformer character? Showing how to get your sprite to change to crouch with the script added in to "duck down" by pressing a button or holding down in a direction? Im noticing that there are hardly any tutorials out there for this but only run and jump.
    But Yes, pretty much like how the old NES Castlevania and Mario games are to duck and attack or duck and avoid enemy projectiles. I'd like to understand the process of that to do it right step by step. Consider it one day in your playlist. it would help a lot. Im trying to understand all of this bit by bit myself so i can contribute to the Unity community with my own tutorials as i learn as much as i can. I support heavy the creation of 2D platformers

    • @bendux
      @bendux  3 года назад +1

      Good idea! I've added it to my list. Thank you for the suggestion!

    • @DemonkaiMugen
      @DemonkaiMugen 3 года назад

      @@bendux Cheers to that. Thanks for considering!

  • @mcrxviii7456
    @mcrxviii7456 Год назад

    Hi!
    how can I put a delay on the teleportation, for example I want to put a fade in and out on the teleportation and put a delay before the player can move.

    • @bendux
      @bendux  Год назад

      The answer to your question goes beyond the scope of a RUclips comment, but I'd still like to help you. Join our Discord server, and let's solve your problem together!

  • @alexd406
    @alexd406 Год назад

    Hello again i have a suggestion, U can do an text that shows you how much fps u got

    • @bendux
      @bendux  Год назад

      I've added it to my list. Thank you for the suggestion!

  • @curryist5049
    @curryist5049 2 года назад

    no offence but do you ever sleep you are always active and help everyone u r the best!!!

    • @bendux
      @bendux  2 года назад +1

      Haha, sleep is for the weak!

  • @chase_exists4299
    @chase_exists4299 2 года назад

    You're amazing, thank you!

  • @AmielShadow
    @AmielShadow 2 года назад

    I want to know the other type of Teleporter anyone knows how is it?

    • @bendux
      @bendux  2 года назад

      We have a solution for that on our Discord server. Feel free to join!

  • @henrikasvaranauskas7508
    @henrikasvaranauskas7508 Год назад

    thanks, this almost works perfectly, the only issue is that i am using two colliders, a box collider and a circle collider, the box collider is so the player cant run through the portal and the circle collider is the trigger so the user needs to be on top of the object to be able to teleport and it works, however once the player is teleported, they are teleported to the sides instead the top of the teleporter.

    • @bendux
      @bendux  Год назад

      You could create an empty game object and position it above your teleporter.

  • @Vitaxses
    @Vitaxses 2 года назад

    can you make so a script remembers the last position and swith to a new scene and teleport the the last positon?

    • @bendux
      @bendux  2 года назад

      The answer to your question goes beyond the scope of a RUclips comment, but I'd still like to help you. Join our Discord server, and let's solve your problem together!

    • @Vitaxses
      @Vitaxses 2 года назад

      @@bendux thankss

  • @skrizford
    @skrizford 2 года назад

    eazy peasy

  • @gudfurt8464
    @gudfurt8464 Год назад

    I have an issue with teleporting my player. I use the teleporter to move to a different level in the same scene, this also implies moving the camera up or down to the new level. Sometimes when the player is teleported he is immediately sucked back to the original position from where he left. Any idea why that happens?

    • @gudfurt8464
      @gudfurt8464 Год назад

      I figured out the cause, if the player moves while using the teleporter he is sucked back to the original position

    • @bendux
      @bendux  Год назад

      Did you accidentally use Input.GetKey instead of Input.GetKeyDown?

    • @gudfurt8464
      @gudfurt8464 Год назад

      @@bendux No, there seems to be a conflict between my player controller and the teleporter script. If i press the E key while moving it bugs out and after teleporting the player and he gravitates to the original position from which he left. My solution was to check if the player is moving when pressing the E key, not sure if there is a more efficient fix

    • @bendux
      @bendux  Год назад

      @@gudfurt8464 Join our Discord server, and let's solve your problem together!

  • @gececiyim87
    @gececiyim87 Год назад

    thanks bro

  • @greplolmain
    @greplolmain 2 года назад

    it says namespace teleporter is nt good

    • @bendux
      @bendux  2 года назад

      Would you like to show me your code on Discord?

  • @frankinocuda
    @frankinocuda Год назад

    The best

  • @tamvo5557
    @tamvo5557 Год назад

    many thanks

  • @curryist5049
    @curryist5049 2 года назад

    Your tutorials are the best

  • @Ghost-zk6ny
    @Ghost-zk6ny Год назад

    Thanks!

  • @jakubkusak714
    @jakubkusak714 3 года назад

    Super video.👍

  • @AbdulAhad-lb4ff
    @AbdulAhad-lb4ff 3 года назад

    Does the velocity of the player stay the same after u teleport

    • @bendux
      @bendux  3 года назад

      Yes!

    • @AbdulAhad-lb4ff
      @AbdulAhad-lb4ff 3 года назад

      @@bendux this is perfect thanks for such quality tutorials

  • @bromar141
    @bromar141 3 года назад +1

    Can someone post the code in the comment section?

    • @bendux
      @bendux  3 года назад

      I've added a link to the source code to the description.

  • @andantrian1638
    @andantrian1638 2 года назад

    🙋♥️♥️🍎