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...
You probably wont see it now, but I would like to thank you either. Good job m8! 😁
Thank you for this video, it is really helpful. The way you explain things is very clear and easy to follow along.
+
agree
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
UR THE BEST MAN TO EVER LIVE
Wait, do OnTrigger methods detect contacts with other triggers and not only whatever touches tis object's trigger-collider?
many thanks, helping me not fail my gaming design assignment
super useful, thanks!
can i have some help ? i get an error: NullReferenceException: Object reference not set to an instance of an object
Would you like to show me your code on Discord?
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
Make sure that your player and the teleporters are in the same position on the z-axis.
Bendux I like your videos, can you make sprite animation tutorials?
I definitely want to make a video about animations in the future.
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?
Would you like to show me your code on Discord?
@@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
@@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.
What do i need to click to teleport?
docs.unity3d.com/ScriptReference/KeyCode.E.html
@@bendux thanks very much. Love your Tutorials.
Thx so much you just got your self another sub +like
OMG 666TH subscriber lol
Thanks for this tutorial! Can you make it so that when the player is teleporting, there is an animation an sound effects?
Yes!
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)
Join our Discord server, and let's solve your problem together!
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?
Would you like to show me your code on Discord?
hello, ı have one problem, when ı am teleported ı cant teleport again before going outside of my portal
Would you like to show me your code on Discord?
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.
We have a solution for that on our Discord server. Feel free to join!
@@bendux I appreciate
delete if (Input.GetKeyDown(KeyCode.E)) and connected {}s
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;
}
}
}
}
People like you keep the world spinning
Man u r great
Thankyou verymuch, This was really helpful to my school game project im doing rightnow, ur the man.
Concise and helpful video, straight to the point. Kudos!
Thank you for this useful tutorial , can you please make a short video on integrating new unity ads scripting for rewaredvideo?
I've added it to my list. Thank you!
My character is disappearing when i use one of my teleporter. Can you help me?
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?
@@bendux yes it goes from 0 to -1793
what can i do?
@@bmo_0143 If possible, set the position of your teleporter on the z-axis to zero.
@@bendux Wow! thank you for the help i fix the z-axis and its working now!
Hey why is it when I use the teleporter it sends me back to spawn?
Make sure that the destination of each teleporter is assigned correctly.
@@bendux ok
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.
nice video, but how do i make a sprite randomly teleport every second. I really need that for my game.
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!
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"
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.
quick and simple.. Nice work.. and thanks!
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
Join our Discord server, and let's solve your problem together!
Thanks!
@@expertarc3861 do you know how to fix it
Yes i was quite new then. but i have a greater understanding now but thanks anyway.
What is the fix?
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.
What kind of error message do you get?
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
Would you like to show me your code on Discord?
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? :(
Join our Discord server, and let's solve your problem together!
Thank you! Really Good Chanel! Good!
WHY DOES NOT SCRIPTS WORK FOR ME IVE BEEN TRYING THIS STUFF FOR LIKE 5 HOURS AND NOTHING WORKS WTF IS HAPPENING!??!?!?!
Join our Discord server, and let's solve your problem together!
you are amazing my man, thank you so much
I made everything the same but something didn't work. Maybe that's code error?
Would you like to show me your code on Discord?
everything okay but where is the teleporter doors and how to add them teleporting funcionality
?
What do you mean?
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?
You can create as many teleporters as you want.
Thank you very much, you saved my day
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
Good idea! I've added it to my list. Thank you for the suggestion!
@@bendux Cheers to that. Thanks for considering!
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.
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!
Hello again i have a suggestion, U can do an text that shows you how much fps u got
I've added it to my list. Thank you for the suggestion!
no offence but do you ever sleep you are always active and help everyone u r the best!!!
Haha, sleep is for the weak!
You're amazing, thank you!
I want to know the other type of Teleporter anyone knows how is it?
We have a solution for that on our Discord server. Feel free to join!
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.
You could create an empty game object and position it above your teleporter.
can you make so a script remembers the last position and swith to a new scene and teleport the the last positon?
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!
@@bendux thankss
eazy peasy
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?
I figured out the cause, if the player moves while using the teleporter he is sucked back to the original position
Did you accidentally use Input.GetKey instead of Input.GetKeyDown?
@@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
@@gudfurt8464 Join our Discord server, and let's solve your problem together!
thanks bro
it says namespace teleporter is nt good
Would you like to show me your code on Discord?
The best
many thanks
Your tutorials are the best
Thanks!
Super video.👍
Does the velocity of the player stay the same after u teleport
Yes!
@@bendux this is perfect thanks for such quality tutorials
Can someone post the code in the comment section?
I've added a link to the source code to the description.
🙋♥️♥️🍎
no
ptt