Smooth PORTALS in Unity

Поделиться
HTML-код
  • Опубликовано: 19 ноя 2024

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

  • @mrspacemonkey3831
    @mrspacemonkey3831 6 лет назад +854

    yes please do a video on writing shaders

    • @tgsoon2002
      @tgsoon2002 6 лет назад +6

      Check out "Makin' Stuff Look Good" channel. It not active much, but the original arthor doing alot of graphic script for unity. Very good source.

    • @SubjektDelta
      @SubjektDelta 6 лет назад +4

      He should do a full series on it.

    • @brendethedev2858
      @brendethedev2858 6 лет назад

      I 161st this

    • @alinawaz4034
      @alinawaz4034 6 лет назад

      yes please make a video on shaders

    • @AD-xt7tg
      @AD-xt7tg 6 лет назад +2

      If you do shaders please do how to make a red dot sight with infinite parallax!!!!!

  • @thevfxwizard7758
    @thevfxwizard7758 5 лет назад +131

    For anyone noticing the one-frame lag, under the PortalCamera script, change void Update to void LateUpdate to draw the portal just before the frame is rendered and after the character movement is calculated.

  • @neomaycry7
    @neomaycry7 6 лет назад +320

    Two things I love about this video:
    1) The pace - You keep a steady pace from beginning to end and never ramble.
    2) The "advanced" lesson - It's difficult to find 'intermediate' and 'advanced' lessons covering Unity. This lesson is great for those of us who have more programming experience and a fundamental grasp of Unity.
    Keep up the great work!

    • @AROD-oh5ez
      @AROD-oh5ez 6 лет назад +6

      Agreed. SO many tutorial makers just ramble and ramble (*cough* TheCherno) and their videos end up being 20+ minutes long when they could be made easily just 10 minutes long. This is why I like Brackeys!

    • @AlexanderZotov
      @AlexanderZotov 6 лет назад +2

      Brackeys is God of Unity for sure)

    • @user-th8nx4cp7w
      @user-th8nx4cp7w 4 года назад +2

      another thing is that some youtuber making tutorial sounds like they are gonna fell asleep

    • @cmdrblaze6487
      @cmdrblaze6487 4 года назад +1

      @@user-th8nx4cp7w And make the viewers fall asleep as a result

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

      ooOKjUauuskakakoaoaoaoo

  • @spoekles
    @spoekles 6 лет назад +180

    Shaders sound SUPER interesting, never really understood what they actually do. Would love a video about this!

    • @Schytheron
      @Schytheron 6 лет назад +1

      Snikur Always wondered what the difference was between a vertex and fragment/pixel shader. Always assumed they were the same thing. Now I know. Thanks!

  • @Mateen_TV
    @Mateen_TV 3 года назад +108

    Make sure that “Auto Sync Transforms” in the Physics section of Project Settings (which can be accessed from Edit) is enabled. If this is not enabled, you’ll find that when your character gets to the Teleport Pad, you’ll be able to see the Teleport Target for a split second but your character will not change position.

    • @kgbchambers
      @kgbchambers 3 года назад +9

      I think I love you? I have been trying to fix this for weeks and it fixed everything

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

      This comment should be the most rated

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

      Wow U r amazing

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

      @@kgbchambers S same here searching for 1 week in unity community page and just found in u tube comment 🤣

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

      I'm really sorry but it still doesn't work. After even trying other's teleport script I realized my player model just ignores the trigger and goes through the planes.... Any reason and how to fix it? I don't know how to code so it's driving me mad....

  • @alexthebassist23
    @alexthebassist23 6 лет назад +193

    A shader video/series would be great. I just want to replicate the grass you made for the shrinking planet game ;)

  • @JujuProdGames
    @JujuProdGames 4 года назад +19

    For anyone wondering why their player is rapidly going back and forth (your screen is probably flickering between rooms really fast), it's because you need to rotate the collider plane by -90 degrees on the x-axis. There goes half my Friday :D

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

      Oh hey you're that guy who made that portal tutorial in 2 minutes. I went and watch yours first before watching Brackeys. Really love the explaining literally at a quick 2 minute pace including quaternions and vectors. Gave me a quick recap during the listening to Brackeys

  • @Xanhomey
    @Xanhomey 6 лет назад +309

    And The Award for the best RUclipsr Ever Goes to Brackeys!!

    • @BrianBakerCA
      @BrianBakerCA 6 лет назад +11

      Seriously, if game dev wasn't such a niche subject he'd be huge! Production quality, teaching style, content choice... Brackeys is amazing

    • @miksuko
      @miksuko 6 лет назад

      That went to LEMMiNO 20 mins ago according to a comment

    • @Rossilaz58
      @Rossilaz58 5 лет назад

      Lemmino? Captain Disillusion?

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

      no surprise if he gets that award

  • @green3y3guy
    @green3y3guy 6 лет назад +128

    Can you make a video on how to do customizable characters? Switching clothes, hair, color, etc.

    • @lavrlevcat
      @lavrlevcat 4 года назад +1

      green3y3guy that would be cool

    • @c1oudsky
      @c1oudsky 4 года назад +12

      isn't that just a bunch of code switching gameobjects and saving what you chose?

    • @lavrlevcat
      @lavrlevcat 4 года назад

      C1oudS well Idk how to make the colour changer wheel that changes the colour of the selected object but u are right tho

    • @c1oudsky
      @c1oudsky 4 года назад +1

      @@lavrlevcat oh well, I guess you should google that instead

    • @lavrlevcat
      @lavrlevcat 4 года назад +1

      C1oudS ok I’ll do so maybe if I’ll made it I’ll make a link for it

  • @sheenufilms
    @sheenufilms 4 года назад +2

    Dude, you are a life saver. Thank you, and please don't EVER stop making videos!

  • @artemis8368
    @artemis8368 2 года назад +4

    To anyone who had an issue with the character jittering or moving rapidly back and forth during teleportation, the issue for me was the first person starter asset.
    Just go to PlayerFollowCamera object. Inside the section called "body", where it says "damping", change the values for x, y and z to 0.
    I was literally looking for this solution for hours and hours.

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

      i can't download the shader anymore. if it's there a link u can give me, i really appreciate it

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

      @@bonusstage6761 same did you find it?

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

      Late, but THANK YOU!

  • @chinmaygawande8008
    @chinmaygawande8008 6 лет назад +1

    Sometimes a professional c# and unity programmer also get confused in some tricky things but brackeys was always there to help me . Thanks for your support always..😀

  • @Vinz_1223
    @Vinz_1223 6 лет назад +3

    The camera sync should be done in LateUpdate to ensure that the camera movement of the player camera controller is done before syncing to the portal cameras to prevent the slight desync jittering you can notice when quickly rotating the camera.

  • @alaslipknot
    @alaslipknot 6 лет назад

    *YES SHADER VIDEOS PLEASE!!* the internet is so full with unity beginner-intermediate tutorials, I have never have the need to write my own shader that's why i never went deep-searching for ressources, but it would feels really good to acquire that knowledge. Thanks!

  • @JustJunuh
    @JustJunuh 6 лет назад +98

    Also, wouldn't it be best to place the "PortalCamera" class's code in LateUpdate()? That way, all the position corrections are done right **after** player movement is calculated and right **before** the frame gets rendered.

    • @loafy8532
      @loafy8532 6 лет назад +1

      i was about to comment that

    • @VeNoM0619
      @VeNoM0619 6 лет назад +19

      Yep, 24:05 you can see the edges of the other portal popping in and out every frame as he moves around.

    • @andreyrumming6842
      @andreyrumming6842 6 лет назад +24

      I have just made a version of this that runs through 4 different rooms before eventually running back to the first one (It took a while but it looks really cool!), but I was having the same issue with the pillars showing up. After taking your advice and putting the PortalCamera class's code in LateUpdate(), the problem pretty much fixed itself. Thankyou so much for this one word modification that greatly increased the quality of my game!

    • @The28studio
      @The28studio 6 лет назад +1

      Yeap that's it !

    • @gialex7240
      @gialex7240 5 лет назад

      Thx my dude

  • @enerzise3161
    @enerzise3161 6 лет назад

    My son and I are talking about using this to make it so players can go into and out of cave missions. We might use CTS Shader to cull the texture where the cave entrance is, so we will not need to use the cameras, but if we did not want to remove the terrain texture, we could use your camera system too.
    Definitely an A++ tutorial.

  • @mwrazer
    @mwrazer 4 года назад +8

    Anyone else watching all of his older vids after he announced they wouldn't make any more? Still hurts but I wish the team at Brackeys a great time doing whatever they are doing

  • @jupitersky
    @jupitersky 6 лет назад +24

    Learning about shaders sounds cool!

  • @Tbrekke
    @Tbrekke 6 лет назад +4

    An interesting conundrum that crops up is when the portals have different rotations. The code for the camera movement is reliant on the portals facing exactly the same way. Anything else and it starts looking weird.

  • @Kappinski
    @Kappinski 6 лет назад +2

    I just paused the Unity course you mentioned to watch some videos. Ben Tristem's courses are great! Funny coincidence that you talk about it :D

  • @Ruxiik
    @Ruxiik 6 лет назад +32

    There's just one issue, the camera seems to be rotating (or rendering) at different times . When you move (for example) sideways you can see the pillars that make up the portal. It's like there's a small delay. Anyway, love the video!

    • @GamesEngineer
      @GamesEngineer 6 лет назад +26

      If you change the name of the Update() function in the PortalCamera script to be LateUpdate(), then that delay goes away.

    • @chlorobyte_projects
      @chlorobyte_projects 6 лет назад +14

      OnPreCull() would be more preferable, pretty much nothing should move the camera after that.

    • @hynnd323
      @hynnd323 4 года назад

      @@chlorobyte_projects Youre right! OnPreCull() works even better than LateUpdate() thank you!

    • @theitalianmonkey
      @theitalianmonkey 4 года назад

      @@chlorobyte_projects Thank you!

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

      @@chlorobyte_projects Thank you

  • @allenlindenberg3732
    @allenlindenberg3732 5 лет назад +2

    Amazing. I got it all working! Which is good as at the time of this post I have zero coding experience! Would just like to say that I had the problem where when I used the portal my player would be teleported back and forth very quickly due to the size of its collider. I solved this by not making the ColliderPlane the receiver. Instead I just made an empty object and put that infront of the portal, made sure it was facing the right way and made that the receiver. Boom, works are charm!
    Thank you so much!

  • @dotsplit
    @dotsplit 6 лет назад +4

    Awesome tutorial and a great effect. The only problem I see immediately is if either room is bigger than the other, so if Room B is bigger than Room A, going to the far edge of Room B will show the outer wall of Room A.

    • @Matt-lm8tj
      @Matt-lm8tj 2 года назад

      Have you found how to dont have this problem ?

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

      @@Matt-lm8tj You could likely adjust the near-clipping plane of the cameras to be the distance from the camera to the portal, but I believe that would cause an issue when viewing the portal from different angles.
      Another solution could be to use some custom shader and mask parts of the view.
      Don't take my word for it though. I never tried these options and the shader one is probably a bit advanced. If you try these, let me know how it went!
      EDIT: Now that I read this comment again, the shader one might not actually work :(

    • @Matt-lm8tj
      @Matt-lm8tj 2 года назад

      @@dotsplit I try to put 2 portals (the gameobject) and the camera in the same emptygame object world and it work, but if the camera or the gameobject portals are not in the same empty game object, i have this bug

  • @fnord_lander
    @fnord_lander 6 лет назад +1

    So glad I subbed. I am a music producer getting into game dev and your videos this past week have been really helpful. Learning at a much faster pace than I thought I would.

  • @trzy
    @trzy 4 года назад +16

    Note: The camera rotation math here is very wrong. It *only* works for yaw (left to right) and pitch (up and down) but will break badly if roll (tilting head side to side) occurs, making it unsuitable for e.g., VR, where your head will never be perfectly aligned with the floor. The correct math is a simple one-liner for rotation. Here is the whole LateUpdate function:
    Vector3 userOffsetFromPortal = Camera.main.transform.position - transform.position;
    m_otherCamera.transform.position = m_otherPortal.transform.position + userOffsetFromPortal;
    m_otherCamera.transform.rotation = m_otherPortal.rotation * Quaternion.Inverse(transform.rotation) * Camera.main.transform.rotation;
    My GameObjects are wired up a bit differently. m_otherCamera refers to the camera in the other map. This script lives on the portal itself (transform). m_otherPortal refers to the other side of the portal, in the other map, where the other camera is observing.

    • @atomlight5568
      @atomlight5568 4 года назад

      I'll test it out thank you 🌹

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

      .

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

      Thank you! Works much better. Wish I could upvote multiple times.

  • @Gunslinger962
    @Gunslinger962 6 лет назад +5

    Shader programming is something that I reallly want to learn but I find it super hard to understand ! Make a video on shader programming too !

  • @JackVXR
    @JackVXR 6 лет назад +27

    how about a video on animating characters like changing weapon and interacting with components etc?

  • @slowswift_I
    @slowswift_I 6 лет назад

    You have so many videos on how to do such cool stuff in unity. How am I ever meant to watch them all. And I want to watch them all.

  • @aleksadjordjic1631
    @aleksadjordjic1631 6 лет назад +9

    You uploaded this video just when i was searching for making portals in Unity , great timing xD

    • @magist7077
      @magist7077 6 лет назад

      true story, i was too, when i make game at was

  • @TomtheMagician21
    @TomtheMagician21 4 года назад +1

    If it’s not working even with a rigid body, remember to change wherever it says other.tag to other.name and make sure that is what your player is named. It took me way too long to figure that out but now it’s great! 👍

    • @vvixell1
      @vvixell1 4 года назад

      no you can use tags

  • @piskez5702
    @piskez5702 6 лет назад +4

    DUDE, THIS THING IS AWESOME, THIS WAS THE EFFECT I WAS LOOKING FOR, I'v seen it some years ago in the stanley parable, and i loved it.
    THANK YOU SO MUCH

  • @aeyedeyen
    @aeyedeyen 5 лет назад

    I've been trying to think of a way to do this type of real time portal in a 3rd person/isometric setting. So war the best I can think of would be facing out the camera from room 1 as you get close to the portal, then once you step through the portal, expanding the area room 2 used to take up into the whole screen. I want to try to work this out but I'm super new w unity. Thank you for making cool videos for newbies like me!

  • @samiyas100
    @samiyas100 6 лет назад +15

    Simple shader tutorial will be awsome.

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

    omg, thank you so much for that screen cut out shader, that's the only thing i needed for my superliminal looking window

  • @dilawar6884
    @dilawar6884 6 лет назад +10

    Up for a shder coding tutorial, and thank for such good tutorials

  • @cmilkau
    @cmilkau 6 лет назад +2

    You dont need to compute angles. You can apply the rotation in the same way as the position, just use quaternion multiplication and division instead of vector addition and subtraction. They are designed to do the equivalent thing in their respective domain.

  • @tristanphipson
    @tristanphipson 6 лет назад +11

    Hey Brackeys, could you please do a tutorial on Custom Shaders?

  • @magnusm4
    @magnusm4 6 лет назад

    Yes do a separate video on shaders!
    Such effects and features are extremely important to know and learn when making any type of game. Do it definitely

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

    RIP Brackeys

  • @tareksalah33
    @tareksalah33 6 лет назад

    Just in time for a VR game i'm working on ... I downloaded the other project from the original video 3 days ago and was going to decipher the code to understand how it works ... Thanks a lot Brackeys for this video

    • @fiend116
      @fiend116 6 лет назад

      Did you use the oculus rift? If so how did you change the code so that it works? I can get the camera previews to look correct but the actual image that is displayed in the rift is incorrect.

  • @Astorec
    @Astorec 4 года назад +10

    Hey all,
    If you can't get the teleport to work, change the void Update() method to void LateUpdate() in the PortalTeleporter script. That should fix your problem!
    If it works give a like to bump it up so hopefully other people can see it!

    • @faban561
      @faban561 4 года назад +1

      Thank you!

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

      didnt work. If I check the player position in the function the position is the teletported one, so i assume, that I get teleported back immeadeately... I use the unity satandard assets character controller, which is the oone used in this tutorial i think..

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

      I will try this
      My player seems like he teleports but he never exits out the other portal instead he exits on the portal he entered

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

      Still sometimes my player does not teleport. Can you help?

  • @babunga
    @babunga 4 года назад

    i love the explanation at the start cant ask for something better than this, obvs there's probably some other ways but tyty

  • @sheroose9177
    @sheroose9177 6 лет назад +3

    Shader would be really interesting i guess

  • @TheBendixSA
    @TheBendixSA 6 лет назад

    Yeah I would love a video on getting started with shaders and shaders basics, and examples of what they can do.

  •  6 лет назад +4

    So, I'm trying to make this with VR. But apparently the code does not detect when the camera rotates on its X axis. (When I tilt my head sideways.). So sometimes the image through the portal stays put at a different angle. How could I change that?

    • @untoldecay
      @untoldecay 5 лет назад

      Hey! I'm trying to do exactly the same. Adapting this tutorial for VR on oculus go.
      I had the same problem as you here. In VR you have stereoscopic vision, so you have to create 1 camera for each eyes, and render the texture on 2 superposed planes ( of course you'll have to create a tag filter to render 1 plane to 1 eye, and the other to the second eye. ) I still have distorsion anyway, that's not the end of the road.
      Here is a little gif untoldecay.com/gif/2goview.gif

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

    Love this. Really great step for step. Took a while for me to follow (4-5 watch-throughs) because I wanted to generalize it into a reusable Portal prefab, but you went through everything with excellent detail and tempo so it was all totally doable. Thank you!!

  • @benoitduinat9885
    @benoitduinat9885 5 лет назад +7

    Great Tutorial.
    How would you adapt to make it work in VR (where instead of having 1 camera A, you have 2 cameras left Eye, Right eye)

    • @ericbergevin1168
      @ericbergevin1168 5 лет назад +4

      If you find an answer to this, can you please post a quick reply here? Thanks

    • @vripro-amberieu518
      @vripro-amberieu518 4 года назад +1

      just put monoscopic on OVRcamera rig. NP.

  • @syedshabih1798
    @syedshabih1798 6 лет назад

    Yes please we really need in depth tutorials on shaders

  • @alejandrogomez4158
    @alejandrogomez4158 6 лет назад +6

    Make a video on how to make shaders

  • @ancapftw9113
    @ancapftw9113 6 лет назад +2

    I'm taking the "learn to code by making games" course. It's a good course for a beginer.

  • @DLRTwentyFive
    @DLRTwentyFive 6 лет назад +5

    Shader tutorials would be awesome!
    I noticed on your render texture it looked like there was a frame of lag when the player moved. Wouldn't putting the "other camera" movement and rotation logic in LateUpdate fix this?
    Also why can't you just say transform.rotation = playerCamera.transform.rotation? Wouldn't that give you the same effect without all the complicated Quaternion math?

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

      You have to consider the rotation in relation to that of the portal's.

  • @tjmorake2743
    @tjmorake2743 6 лет назад

    You do the best tutorials i just can't stop liking your videos

  • @jadw1
    @jadw1 6 лет назад +11

    Yes :D Make sth with shaders :D :D

  • @Schytheron
    @Schytheron 6 лет назад

    Hands down the greatest tutorial that exists on RUclips. Have been looking for a good tutorial on this for sooooo long!

  • @lordofduct
    @lordofduct 6 лет назад +9

    So twice now people have come into the Unity forums after following this tutorial because the implementation does not compensate for proper rotations. I cleaned the code up the first time, and since shared it again the second time.
    Here's the original thread when someone came in with problems:
    forum.unity.com/threads/portals.522231/
    I removed your 'PortalTextureSetup' class because this honestly is just garbo adhoc code that shouldn't be used.
    I moved the render camera positioning to LateUpdate (which I saw several commentors bring up here as well).
    I used an event driven teleportation instead of the adhoc approach done in this video.
    And of course... fixed the glaring rotational issue. You should try rotating your 2 rooms when testing.
    Anyways, here's the git project I modified for it:
    github.com/lordofduct/PortalsDemo

  • @Lloydchen07
    @Lloydchen07 6 лет назад

    I would greatly appreciate a video (or a series) on shaders from you, Brackeys. In almost every gaming project I'm working on right now, there's a point at which specific tasks would be that much easier or more effective if someone on the team could write shaders in Unity.
    I find them very complicated and scary, but I believe a video from you could really help me to get started with shaders in general.

  • @liveisamelody9413
    @liveisamelody9413 6 лет назад +3

    i had a bug where camera a and b where rotated exactly to the oposite side of the portal, by that i mean if i was looking through the portal the cam on the other side was basicaly also looking through the portal, in this case if there where objects on the other side and i didnt ran into the portal i wasnt seeing them.... but i fixed it just by going into the "PortalCamera" script and at line 25 (in your video its line 18) i multiplyed "angularDifferenceBetweenPortalRotatoins" by 2 so the cam was twisted by 180° again, facing the same way the global cam was facing.
    and that basicaly removed that mirror effect on both cameras and instead showed me exactly whats going on on the other side.
    and you also got it wrong in your video brackeys, so i hope this fixes it. and it shows it the right way if both rooms have the same global world rotation and just the portal is rotated by 180°.
    i hope this helps some people out and SUPPORT BRACKEYS! because he is friendly and comes up with great ideas. :)
    i think i dont need to mention that i wouldt had be able to come up with the portal thing, mostly because am lazy^^.

    • @jacobfoster9358
      @jacobfoster9358 6 лет назад

      I need help, the portal is flipped upside down. Even when i flip the camera 180 on the x axis, nothing happens

    • @jacobfoster9358
      @jacobfoster9358 6 лет назад +1

      Thank you so much, now I have a solid game!

  • @thomaslaganda4354
    @thomaslaganda4354 6 лет назад

    Hello abjourn, I would just Like to thank you for all your help! You are the best programming tutor in the world!

  • @dhedarkhcustard
    @dhedarkhcustard 6 лет назад +3

    You can see there's about 1 frame delay of the objects inside the portal, is there a way to fix this? It's more obvious on slower machines.

    • @The28studio
      @The28studio 6 лет назад +2

      James Heazlewood use LateUpdate() instead of update .

  • @pierrethehandsome2518
    @pierrethehandsome2518 6 лет назад

    You've earned yourself a subscriber! This technique worked very well and I learned a lot more about quaternions while following along. I was even able to create an infinite corridor effect in addition to a portal by altering the portalteleporter script. Your videos are very high quality and you explain things properly and concisely. A tutorial on shaders would be nice as that sort of stuff is like ancient atlantean to me.

  • @Amuntsen
    @Amuntsen 6 лет назад +3

    This *barely works on beta 2018.3.0b7, there seem to be some issues with changing the transform.position of player with active Character Controller component.
    * There are major glitches on moving from RoomA to RoomB, oddly the other way works just fine.

    • @davidclark5523
      @davidclark5523 5 лет назад

      Works fine for me, using version 2018.3.10f1

  • @Hamstermoviespro
    @Hamstermoviespro 6 лет назад

    Render Textures and Shaders are super powerful elements, please do a video explaining how they work!

  • @paspiregamer5114
    @paspiregamer5114 6 лет назад +4

    brackeys I download your sene and at the first look all is ok but if i go on the green place and I take the portal on the wrong way i go in the red place but the portal do not work any more. Can you help me or fix this plz. And a big thank you for all your video you help me so mush :)

    • @jeremiebeaulieu8501
      @jeremiebeaulieu8501 6 лет назад

      put annother plane just behind the portal, put a box colider on it and don't click on "is trigger" and disable mesh renderer ;)

    • @paspiregamer5114
      @paspiregamer5114 6 лет назад +1

      yes I will do this if brackeys dont fix this

  • @ferna2294
    @ferna2294 6 лет назад

    You are a genius. That quaterinion stuff code was marvelous.
    Thank you!

  • @hapdio4331
    @hapdio4331 3 года назад +6

    If your character isn't teleporting, you need to turn off and on your character controller momentarily while teleporting by using this line of code:
    player.GetComponent().enabled = false;
    This is what it looks like after applying:
    player.GetComponent().enabled = false;
    // teleport:
    // rotation
    float rotationDifference = -Quaternion.Angle(transform.rotation, reciever.rotation);
    rotationDifference += 180;
    player.Rotate(Vector3.up, rotationDifference);
    // movement
    Vector3 positionOffset = Quaternion.Euler(0f, rotationDifference, 0f) * portalToPlayer;
    player.position = reciever.position + positionOffset;
    player.GetComponent().enabled = true;
    playerIsOverlapping = false;

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

      Thank you SOOO much. I was having trouble with this and knew it was something to do with the Character controller but didn't know how to fix it!!!

    • @DuyDoan-bh7oc
      @DuyDoan-bh7oc 2 месяца назад

      excuse me, this code will be added to Player Object, right ?

  • @docyo8685
    @docyo8685 4 года назад

    That's Antichamber in a Nutshell. well done. I appreciate all the video you're making.

  • @altermann4072
    @altermann4072 4 года назад +11

    For the people who can't download that shader from description link
    drive.google.com/file/d/1P3HSi7alDGttF9R98xDW7OhtswLO1FHm/view?usp=sharing

    • @codyc1267
      @codyc1267 4 года назад

      Thank you so much. I was looking for something like this.

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

      a hero

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

      actual legend

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

      a year later and still a hero

  • @WelshDdraig
    @WelshDdraig 6 лет назад

    That learn to Code by Making Games in C# with Unity on Udemy is great.
    I bought it last year, and it is amazing. so useful. The tutor also has an Unreal version.
    For once - somebody with a sponsor that I recommend.

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

    That is great! Many thanks for the work putting it together!
    Any recommendations on how to port this project to VR?
    I implemented it as is and on my VR game and the portal has a weird looking.
    Each eye camera is rendering the same portal camera and the render plane gets fuzzy in the VR.
    I believe one has to duplicate everything and select the eye camera where it gets rendered... is that right?

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

      Hi! I’ve been having the same issue… we’re you able to fix this somehow?

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

      @@julianicolescu149 did you ever find a solution? I haven't tried this yet but I do know you should be using the center eye camera instead of either left or right.

  • @jx4219
    @jx4219 6 лет назад

    So that's how easy it is. I was searching for this everywhere like ~2 years ago and the only thing i found was a portal you could look trough but then just teleports you when you walk trough it and not let you walk trough it seamlessly. I thought it's just not possible yet but it seems to be rather simple.

  • @vistaero
    @vistaero 6 лет назад +8

    What if I want to have a different rotation on each portal? this only works if both have the same rotation.

    • @AHSEN.
      @AHSEN. 4 года назад +1

      ruclips.net/video/cWpFZbjtSQg/видео.html Sebastian Lague has a video on that. His is a a lot more complicated I believe, but he shows the entire process, and has even shared the source code so you can check it out yourself.

  • @ToniPlays_
    @ToniPlays_ 6 лет назад

    Love your tutorials😍 I watch at least one video in a day. Keep it on Brackeys

  • @bmg.rogames3551
    @bmg.rogames3551 6 лет назад +3

    Brackeys I have started working on a new game and I want my players to have a level editor we’re they can make their own level like in Geometry Dash but I do not know how, can you do a tutorial on a level creator for the players?

  • @jaycelee8453
    @jaycelee8453 6 лет назад

    cannot be more thankful

  • @nicolasg3305
    @nicolasg3305 6 лет назад +7

    For rotation can’t we do transform.rotation = firstcamera.transform.rotation ?

    • @chlorobyte_projects
      @chlorobyte_projects 6 лет назад +2

      What if your portals are angled differently?

    • @Xaaaach
      @Xaaaach 5 лет назад

      Benedani You have a point, but I think in this situation what he suggested might work.

    • @chlorobyte_projects
      @chlorobyte_projects 5 лет назад

      Yeah but you'd need to ensure the two portals have the exact same orientation. It's just a dumb limit that you can easily fix by following the tutorial properly.

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

    thanks for hauling me through my game production course

  • @fatratstew
    @fatratstew 6 лет назад +3

    Awesome tutorial! There is a bug in your shader though, it breaks when the camera is rotated on the Z-axis. How can I fix this? Thanks!

  • @tdba316
    @tdba316 6 лет назад

    Yes please have a series on shader writing!

  • @H1imachicken
    @H1imachicken 6 лет назад +22

    should give credit ruclips.net/video/iHqjscifPnI/видео.html since its the exact same layout and everything

    • @JayFoDra
      @JayFoDra 6 лет назад +3

      Look in the description.

    • @H1imachicken
      @H1imachicken 6 лет назад +1

      Creepiable he added that after I posted this , as I already checked before I posted

    • @tippinggame2799
      @tippinggame2799 6 лет назад

      The same~OMG

    • @ridlr9299
      @ridlr9299 4 года назад

      @@tippinggame2799 is brackeys a fraud lol? :)

  • @2dinunity10
    @2dinunity10 6 лет назад +1

    This is sweet! Kind of similar to the 2d portal tutorial made. I also wrote a shader that ripples the portal view which adds a nice effect

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

    unable to download shaders

  • @raz3743
    @raz3743 6 лет назад

    You can not believe in how good time you did this video

  • @goldcobraarima9819
    @goldcobraarima9819 6 лет назад +4

    Why is the depth 24?

    • @djpeterson7479
      @djpeterson7479 5 лет назад +1

      I know this is an old comment, but for others who are wondering: it's 24-bit because it's 8-bits per channel. You have three primary channels in a texture that give you all your colors: red, green and blue. Each channel is a single byte per pixel (8 bits). So 8 * 3 = 24. If you are wondering why no alpha, probably because he's not using opacity.

  • @1e1001
    @1e1001 6 лет назад

    If you have a camera that renders only some elements placed on the player camera, and add the shader and material and stuff, you can make an object that hides objects behind it. I used this for some projects to hide map objects that I don't want to see for windows and stuff

  • @kivo3592
    @kivo3592 4 года назад +6

    is it just me or did this not work even tho i tried a million times and did exactly what he said? Just Me.

  • @Eclipsed_Archon
    @Eclipsed_Archon 6 лет назад +1

    Wish I watched this before I went and figured it all out myself... I didn't use the shader trick, since I don't write shaders often, and since I had portals at all different angles, within one continuous level, I had to do some math to figure out the proper position and angle for my portal camera... The annoying part was realizing halfway through that my portals only looked right when rotating around a single axis, so then I had to go back and redo all my math...
    Then unrelated I had a dumb issue with my jump script, since I use physics based inertia, but store that starting inertia for the sake of some complex double-jump shenanigans. So when my character got forcibly rotated when moving through the portals, if they were mid jump the direction of travel would get screwed up... In the end I'm glad it was just being done as an exercise, took way too long to get it running right without any bugs.
    If I learned anything from this experience at all, it's never to underestimate just how much a single design choice can influence and screw you later down the road...

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

    Does anyone know how to solve inconsistent collision detection? As it works but the colliders don't always register it.

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

      Im wondering the same, mine works sometimes and then other times it doesnt :(

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

      yea its about that the collider is very thin your pc doesnt detect it because it processes slow you probably have a bad pc u can solve this by making the collider thiccer if u know what i mean

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

      @@phairz1168 Tried that, it kinda worked more consistently but still consistently doesnt

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

      @@WarriorH ye it seems that u better not do that and it fully worked when u open Project Settings > physics > autosync transform (Enable) it should be smooth

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

      @@phairz1168 thanks ill give it a go :)

  • @EL-cb1nu
    @EL-cb1nu 4 года назад

    You win the internets of the decade!

  • @RKD1010
    @RKD1010 6 лет назад +4

    95% of comments: Comments asking for a Shaders video
    4% of comments: Vague comments asking for tutorials about something
    1% of comments: Actual comments that talk about the video and are worth reading

  • @The28studio
    @The28studio 6 лет назад +2

    Now if you are saying , holy crap ! What if my worlds are big ?
    Its simple : take a note from subnautica portals , if you didn't see em check em out .
    What you do is you put your portals into closed areas like caves !
    This way you only load the cave on the render to texture and when the player cross the portal to the cave you start loading the new area ( or stream it )

  • @Thomas-wd8zm
    @Thomas-wd8zm 6 лет назад +47

    Make a tutorial how to get your game on a phone

    • @Androidus3
      @Androidus3 6 лет назад +4

      Thomas N3K has a very nice tutorial on it

    • @kurtisknodel
      @kurtisknodel 6 лет назад +2

      File > Build Settings > Then Switch Platform to Android/iOS. You'll need to install a few things, but then it'll run.

    • @ChromesClips
      @ChromesClips 6 лет назад +2

      Huge headache saver for people trying and failing to build to an Android. If you're having errors building don't use JDK 9, use any version of JDK 8. If problems still persist download an older version of sdk.

    • @magnusm4
      @magnusm4 6 лет назад +2

      FUCK.PHONES!
      You watch fucking Brackeys with awesome tutorials of many things AND YOU WANT TO WASTE IT ON TRASH MADE BY IDIOTS WHO ONLY WANT MONEY! You have the fucking tutorials right here, make a real game instead.
      It's like downloading Opentoonz and just use the tools to make poor flash animations with images from MS Paint

    • @Dxpress_
      @Dxpress_ 6 лет назад +6

      *+magnusm4* Chill out dude. It's not like you can't do both.
      Edit: Also, Brakeys has done streams on how to create various mobile games.

  • @komsununoglu1322
    @komsununoglu1322 6 лет назад +1

    I would definately love to watch you explain shaders

  • @explogeek
    @explogeek 5 лет назад +6

    “It’s simple, just use the file I made”. Kind of defeats the purpose, if you’re not showing how to make this from scratch...

  • @nchutchind
    @nchutchind 6 лет назад

    Great video! The only criticism I would have is that the portal gate changes color as you go through it, which takes away from the effect (ie, go through the portal sideways and watch the arch change color suddenly). I think it would be better if the gate was the same color on both sides, or if the rendered view through the portal included the gate on the other side (ie, you would see the green archway when looking through the portal from the red side and vice versa).

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

    The transport and rotation of player can be simplified in complexity by using quaternions directly instead of casting to angles. It will be a bit cleaner but also confusing for people who are used to thinking of angles as degrees rather than algebraic lenth. I suspect you can abuse lerp and transform definitions to skip the dotP too, as the result of the lerp will have the same properties as the dotP. q1 to q2 is the same as q2 to q1 this means you can just check if the lerp result is small enough. Because the maximum result is discarded, the minimum result will always be less than or equals to half a revolution; so if its less than lets say a quarter revolution you know its entering from the correct direction. Now this lerp itself is the Quaternion rotation you need to apply when rotating the player, so no need to cast to euler angles, all you need to do is set the Transform = receiving tansform and apply the lerp. Its something like 4-6 lines of code less. And it is fewer calls and cheaper math overall. If you experience fps stutters on tp, you can try this. Not that i think that is common, but the less time you need to complete the tp, the less strain it is on the cpu. If someone tries both please let me know if you could detect a performance difference. I dont have a portal game in works atm.

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

      if its confusing you can read: en.wikipedia.org/wiki/Slerp#Quaternion_Slerp

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

    ALL HAIL BRACKEYS let his vedios live forever

  • @itsttsi3858
    @itsttsi3858 4 года назад +1

    Brackeys: it doesn't have to be perfect
    Also Brackeys: proceeds to make it perfect

  • @JustinsDustyShelf
    @JustinsDustyShelf 9 месяцев назад

    That’s so cool dude I’m definitely gonna try that

  • @marian519
    @marian519 6 лет назад

    This approach will render things that are behind the portal in the other world, which you shouldn't see. Maybe this could be fixed with a replacement shader or by changing the clipping plane.

  • @amadmaul
    @amadmaul 5 лет назад

    I just wanted to know how to teleport but I found something more. Great Brakeys.