HOW TO TELEPORT OBJECTS IN UNITY 🎮 | Teleport Player and GameObjects in Unity | Unity Tutorial

  Рет қаралды 48,104

Dani Krossing

Dani Krossing

Күн бұрын

Пікірлер: 72
@Dani_Krossing
@Dani_Krossing 3 жыл бұрын
A friendly commenter on my last video corrected a mistake, where I say that you need to reference scripts inside the Awake(), when it is actually supposed to happen inside the Start(). 🙂 Unfortunately I made these two videos at the same time, so I make this same mistake in this one as well hehe. Whops. 😅
@rigoabell4863
@rigoabell4863 2 жыл бұрын
thx
@Envy-Animations
@Envy-Animations 9 ай бұрын
Yikes
@TheGloriousJeb
@TheGloriousJeb 2 жыл бұрын
Got it to work without disabling movement, used wait for end of frame instead of wait for seconds before changing position. Appreciate the help, spent the whole day tinkering on this.
@sherilynneherb4854
@sherilynneherb4854 2 жыл бұрын
Could you please explain?
@duckenomics7981
@duckenomics7981 9 ай бұрын
I love how slow you go through things! As a unity and coding beginner i feel like most tutorial fly past the details and I tend to get lost easily because of it. I will definitely sub and take a look at some of your other tutorials when I get the chance.
@SuperOsmaniac
@SuperOsmaniac 9 ай бұрын
Thanks for the tutorial! You've saved my day! I'm not very experienced with c# and have spent several hours trying to teleport my player without disabling a controller! =)
@Akaimari-kw8og
@Akaimari-kw8og Жыл бұрын
I was literally stuck on this for 2hours, no being able to teleport my player, you saved me! Thank you!!!
@real_unreal9644
@real_unreal9644 10 ай бұрын
Thank you so much for this awsome tutorial. Ive been having issues for the last 3 hours but you saved me :D
@zengtian9451
@zengtian9451 2 жыл бұрын
Gosh Dani I've been using playmaker to set the player's position but continuously face the same 'teleport issue' you mentioned after deactivating the player everything is going well. You help me a lot really really thanks.
@superkitten7560
@superkitten7560 3 жыл бұрын
I know exactly zero about coding or programming and I have no idea what I just watched...but I still enjoyed it. Two thumbs up and a "like" lol
@creepermods4641
@creepermods4641 Жыл бұрын
Thank you so much bro. I'm working on Mobile Teleportation
@lobbywww
@lobbywww 2 ай бұрын
Nice work explaining this, thanks a lot! I'm trying to emulate elevator movement using teleportation. Using delay is a perfect approach.
@vraj2003
@vraj2003 3 жыл бұрын
hey I have been learning php recently and your videos are helping me a lot, just wanted to say thank you.
@MatthiasGut
@MatthiasGut 3 жыл бұрын
Hello 😁Nice video, thumbs up! Since you were wondering how fast you can execute the coroutine; What you could do as well is 'yield return null'. That will wait for one frame and it will be enough to teleport the player. It might be of interesst why exactly that behaviour is happening at all and that little mystery I think I can explain. The reason is that the CharacterController component stores the position of the object in its own field and applies that position to the position field of the Transform component on every frame, basically overwriting the teleport input since the only official way to alter the position of the CharacterController internally is by using the Move() or MoveSimple() method of the CharacterController itself. Every time the CharacterController gets enabled it reads the position of the Transform component, therefore refreshing/overwriting the previous position stored. So technically it should be enough to only disable the CharacterController component itself, then teleport and after that enable it again. Might be preferential if you don't want to restart other scripts on the player object. Why exactly you weren't able to do all of it in the same frame I'm actually not sure about, might be some conflicht with the PlayerController script itself. Since I'm a lazy typer, what I do is using a little extension method for the CharacterController itself: public static class CharacterControllerExtensions { /// Moves the character controller (Transform) to specified position. /// Target position public static void TeleportTo (this CharacterController controller, Vector3 position) { controller.enabled = false; controller.transform.position = position; controller.enabled = true; } /// Moves the character controller (Transform) by specified vector. /// Vector to be moved by public static void TeleportBy (this CharacterController controller, Vector3 vector) { controller.enabled = false; controller.transform.position += vector; controller.enabled = true; } } Why unity itself isn't including functionality for that out of the box I don't understand. It's a hack as well, obviously, but it's a lot less typing and way less cluttered code. Extensions might be a bit far of for the tutorial series, maybe, but I thought I share this with you guys anyway. Another solution could be overwriting the position field of the CharacterController directly using System.Reflection, but that's way to advanced stuff for the tutorial series at this point. 🤣
@Dani_Krossing
@Dani_Krossing 3 жыл бұрын
Oh cool! Didn't know 'yield return null;' would have the same effect. 😀
@КибершколаСмарторика
@КибершколаСмарторика 5 ай бұрын
It works for me with CharacterController. Thank you very much!
@lukaspaver
@lukaspaver Жыл бұрын
Thanks Dani. I've been stuck for way too long on this bug in my game.
@GhostSy_
@GhostSy_ 8 ай бұрын
Thanks I was stuck there that was right very helpful.
@eznogamee3704
@eznogamee3704 3 жыл бұрын
thanks soooooooooooo much for this video, i have struggle with this function in my game for days!!!! finally solve it
@SteadyPaceVince
@SteadyPaceVince 2 жыл бұрын
yo the best, I really needed this
@amitbt69
@amitbt69 Жыл бұрын
Great Tutorial! thanks.
@Graviteam
@Graviteam Жыл бұрын
Genial, hat mir sehr geholfen!!
@ggshout3019
@ggshout3019 5 ай бұрын
Thank you, disabling the rigidbody with this method made my Teleport Skill work each time now. I was baffled what's the reason for it only working sometime.
@darklord1817
@darklord1817 2 ай бұрын
thank u so much!!!!
@i1234pipio
@i1234pipio 3 жыл бұрын
Very useful info!! Thank you so much!
@gmangman123
@gmangman123 Жыл бұрын
Thx so much master!
@_SF_Media
@_SF_Media 3 жыл бұрын
Thanks for the video, it did help a little with one issue I had. Perhaps you could make something like this video that deals with multiple teleport spots? For example A -> B with option to go to C,D, or E from a list. IF you have the time, willingness and skills to do so that is. Not found anything like this out there yet.
@Dani_Krossing
@Dani_Krossing 3 жыл бұрын
I will have a video up on that tomorrow 😊
@u2bt257
@u2bt257 Жыл бұрын
Love the detailed explanation! Is there any chance to make this a lerping/smooth movement instead of an instant?
@RizevimVanZ
@RizevimVanZ 11 ай бұрын
Perhaps chatgpt isnt as good as it sounds, thanks for the tut!
@tLr1n
@tLr1n 2 жыл бұрын
what is UpdateMouseLook and UpdateMovement at 6:20? Is it just your movement and mouse look scripts with the word update in front of them? Because when i do the same thing it says it doesn't exist
@sayed_technical
@sayed_technical 3 жыл бұрын
Hi I am sayed from Bangladesh... I like your videos....
@sayed_technical
@sayed_technical 3 жыл бұрын
i want to contact you.. please give me your contact address.. if you're set your WhatsApp number, then please give me your WhatsApp number please brother...
@rudikrasna6846
@rudikrasna6846 Жыл бұрын
thank you so much
@thewaterwasfine
@thewaterwasfine 11 ай бұрын
spent the past 4 hours wondering why i couldnt get my player to teleport then came across this godsent video. unfortunately 0.01f is too fast for OnTriggerEnter teleporting so i think im just going to have to make a physics based playercontroller
@pulinho5451
@pulinho5451 8 ай бұрын
thx!
@JuliaEsAwesome
@JuliaEsAwesome 3 жыл бұрын
Ik this is off topic of your video but do you know how much you will charge to check over someone ecommerce website-and let them know what they need to fix and add
@Dani_Krossing
@Dani_Krossing 3 жыл бұрын
I don't do that type of service :) And to be honest I'm more of a front end developer than a back-end developer, so I wouldn't be able to help if it came to it.
@Sharky.Sharky.Sharky
@Sharky.Sharky.Sharky 17 күн бұрын
You can also turn off the gameObject and then turn it back on very quickly
@FadilSyhptra
@FadilSyhptra 2 жыл бұрын
Thank You!!!
@dertobbe1176
@dertobbe1176 Жыл бұрын
Hi, I made some kind of UT 2004 transcolator. I just said player.position = transcolator.position... It Kanada works. But not always. My guess is that's it's about the right frame... How can I be sure to Set the New Position to the translocator Position no matter what?
@heykuze
@heykuze 2 жыл бұрын
What if teleporting on an empty game object? And only when in an trigger to be able to? You need to add on onColliderEnter?
@regys9521
@regys9521 2 жыл бұрын
I loved it
@patelvraj1362
@patelvraj1362 Жыл бұрын
one question : what i want to teleport an object that i have Instantiate in game ?
@TheDuckter
@TheDuckter Жыл бұрын
instead of clicking, is there a way to detect a colision with another object? (e.g: portal)
@TheDuckter
@TheDuckter Жыл бұрын
PS its a vr game
@darkman237
@darkman237 2 жыл бұрын
Now if you wanted to go back to the first plane and end up at the same place you hit the button, how would that be accomplished?
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
Just store your Vector3 at the moment of pressing the button, and then use that as your last teleported location. 🙂
@deadevil_fst
@deadevil_fst 7 ай бұрын
Thanks used this to make windows jump 😂
@zoomiee6229
@zoomiee6229 2 жыл бұрын
Can I do this with “SetActive” instead of enabled?
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
Sure, I can't see why not. 🙂
@zoomiee6229
@zoomiee6229 2 жыл бұрын
How could i do this with a "OnTriggerEnter(Collider other)" method? Because im trying to do this with a vr game. Im just going to send my code here with what i have and if you can tell what I can do to fix it because I get a double float error.
@legoose
@legoose 2 жыл бұрын
Hi, Visual studio noob here. Would you kindly inform me how to turn on (not 100% sure what it's called) the auto complete. I've been looking at visual studio for the last two hours and still haven't found the settings.
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
My "how to install Unity" video shows how. :)
@Omnivoid22
@Omnivoid22 10 ай бұрын
I cant find a tutorial that shows how to teleport a character, when they press a button
@johanneswagenknecht737
@johanneswagenknecht737 2 жыл бұрын
Hey @Dani Krossing, I was wondering what the sign after playercontroller in line 12 is? Please help me because im going to fail IT class.
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
One of the most useful and often used skills of any IT person, is Google. 🙂 If you search "What are the symbols called?" then you will find your answer. It took me 20min to see your comment and reply, where as a Google search takes 10sec. 😉Not trying to sound snarky hehe (maybe a little).
@Stoney_Eagle
@Stoney_Eagle 3 жыл бұрын
I don't have Danish translations implemented yet so I thought I just do one where it matters the most to me... Howcome a 3-word sentence is wider in pixels in Danish than the English version even tho they are the same character length? 😂😅😭 It's that crazy æ symbol I guess, my dynamic font size calculation doesn't work because of it... It's a good thing I see it now before release.
@lotfitej8101
@lotfitej8101 2 жыл бұрын
This has been fixed on latest Unity update. No need to use couroutine.
@StickyLabDev
@StickyLabDev 8 ай бұрын
"sometimes failed" is why im here
@devonlewis444
@devonlewis444 2 жыл бұрын
okay, so Is there a way to teleport a specific distance? instead of to a certain object? because I'm making a game where a monster is at the end of a hall way, teleporting towards you every 5 seconds or so, and I was wondering if there was a way to make it move a specific distance, and maybe to randomize the location of where it teleports to in between the walls. (sorry, I know that might be a lot, but I'm kinda lost lol)
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
You can create a Coroutine that runs a function every 5sec, and then inside the function you get the direction towards the player using a normalized offset of the player and the monster, and just add the distance you want it to teleport. 🙂 This video can help you getting the offset: kzbin.info/www/bejne/aWHCpKOIaMh2rtk&ab_channel=DaniKrossing
@devonlewis444
@devonlewis444 2 жыл бұрын
​@@Dani_Krossing Update, I've figured out the code. XD My only issue now is that I used a Random.Range for the x axis, so that it would move around the hallway when it teleported. But the range I set moves with the object, so sometimes it teleports outside of the hallway. and I have no idea what a solution would be to that. .-.
@alex_ig_
@alex_ig_ Жыл бұрын
you look like if elon musk made video games. no offence
@3th1nhawn50
@3th1nhawn50 2 жыл бұрын
i acidently made a teleport its not that complicated
@3th1nhawn50
@3th1nhawn50 2 жыл бұрын
just take dani grapple gun script and make it a fixed joint instead of spring joint
@PlaceholderNameRandomNumber
@PlaceholderNameRandomNumber 2 жыл бұрын
you Talk and Move like Elon Musk, wtf...
@PerplexingRat
@PerplexingRat 4 ай бұрын
player controller isnt a thing
@canalataquerapido
@canalataquerapido 2 жыл бұрын
Jesus... so much coding for this
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,2 МЛН
Чистка воды совком от денег
00:32
FD Vasya
Рет қаралды 5 МЛН
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 7 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 101 МЛН
How I learned Unity without following tutorials (Developing 1)
18:11
Game Maker's Toolkit
Рет қаралды 2,1 МЛН
THIRD PERSON MOVEMENT in Unity
21:05
Brackeys
Рет қаралды 1,5 МЛН
If You Can't Make Games After This Video...
4:37
Fredyy
Рет қаралды 1 МЛН
I never understood why you can't go faster than light - until now!
16:40
FloatHeadPhysics
Рет қаралды 4,2 МЛН
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 735 М.
How to Learn Game Art!
15:04
Nonsensical 2D
Рет қаралды 124 М.
SCRIPTABLE OBJECTS in Unity
8:57
Brackeys
Рет қаралды 1 МЛН
Uncover the Simple Trick to KEEP MUSIC PLAYING Between Scenes!
4:42
Чистка воды совком от денег
00:32
FD Vasya
Рет қаралды 5 МЛН