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.
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!
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!
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!
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.
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....
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
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
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.
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..😀
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.
*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!
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.
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!
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.
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
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.
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!
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!
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 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 :(
@@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
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.
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.
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! 👍
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
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!
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.
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
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.
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!
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..
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?
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
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!!
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?
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
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.
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^^.
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.
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.
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 :)
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;
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.
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 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.
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.
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.
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?
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.
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.
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
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...
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 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
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
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 )
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.
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
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).
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.
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.
yes please do a video on writing shaders
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.
He should do a full series on it.
I 161st this
yes please make a video on shaders
If you do shaders please do how to make a red dot sight with infinite parallax!!!!!
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.
Thanks!!!
thx
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!
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!
Brackeys is God of Unity for sure)
another thing is that some youtuber making tutorial sounds like they are gonna fell asleep
@@user-th8nx4cp7w And make the viewers fall asleep as a result
ooOKjUauuskakakoaoaoaoo
Shaders sound SUPER interesting, never really understood what they actually do. Would love a video about this!
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!
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.
I think I love you? I have been trying to fix this for weeks and it fixed everything
This comment should be the most rated
Wow U r amazing
@@kgbchambers S same here searching for 1 week in unity community page and just found in u tube comment 🤣
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....
A shader video/series would be great. I just want to replicate the grass you made for the shrinking planet game ;)
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
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
And The Award for the best RUclipsr Ever Goes to Brackeys!!
Seriously, if game dev wasn't such a niche subject he'd be huge! Production quality, teaching style, content choice... Brackeys is amazing
That went to LEMMiNO 20 mins ago according to a comment
Lemmino? Captain Disillusion?
no surprise if he gets that award
Can you make a video on how to do customizable characters? Switching clothes, hair, color, etc.
green3y3guy that would be cool
isn't that just a bunch of code switching gameobjects and saving what you chose?
C1oudS well Idk how to make the colour changer wheel that changes the colour of the selected object but u are right tho
@@lavrlevcat oh well, I guess you should google that instead
C1oudS ok I’ll do so maybe if I’ll made it I’ll make a link for it
Dude, you are a life saver. Thank you, and please don't EVER stop making videos!
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.
i can't download the shader anymore. if it's there a link u can give me, i really appreciate it
@@bonusstage6761 same did you find it?
Late, but THANK YOU!
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..😀
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.
*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!
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.
i was about to comment that
Yep, 24:05 you can see the edges of the other portal popping in and out every frame as he moves around.
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!
Yeap that's it !
Thx my dude
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.
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
Learning about shaders sounds cool!
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.
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
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!
If you change the name of the Update() function in the PortalCamera script to be LateUpdate(), then that delay goes away.
OnPreCull() would be more preferable, pretty much nothing should move the camera after that.
@@chlorobyte_projects Youre right! OnPreCull() works even better than LateUpdate() thank you!
@@chlorobyte_projects Thank you!
@@chlorobyte_projects Thank you
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!
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.
Have you found how to dont have this problem ?
@@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 :(
@@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
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.
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.
I'll test it out thank you 🌹
.
Thank you! Works much better. Wish I could upvote multiple times.
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 !
how about a video on animating characters like changing weapon and interacting with components etc?
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.
You uploaded this video just when i was searching for making portals in Unity , great timing xD
true story, i was too, when i make game at was
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! 👍
no you can use tags
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
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!
Simple shader tutorial will be awsome.
omg, thank you so much for that screen cut out shader, that's the only thing i needed for my superliminal looking window
Up for a shder coding tutorial, and thank for such good tutorials
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.
Can you expand on this?
Hey Brackeys, could you please do a tutorial on Custom Shaders?
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
RIP Brackeys
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
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.
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!
Thank you!
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..
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
Still sometimes my player does not teleport. Can you help?
i love the explanation at the start cant ask for something better than this, obvs there's probably some other ways but tyty
Shader would be really interesting i guess
Yeah I would love a video on getting started with shaders and shaders basics, and examples of what they can do.
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?
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
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!!
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)
If you find an answer to this, can you please post a quick reply here? Thanks
just put monoscopic on OVRcamera rig. NP.
Yes please we really need in depth tutorials on shaders
Make a video on how to make shaders
I'm taking the "learn to code by making games" course. It's a good course for a beginer.
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?
You have to consider the rotation in relation to that of the portal's.
You do the best tutorials i just can't stop liking your videos
Yes :D Make sth with shaders :D :D
Hands down the greatest tutorial that exists on RUclips. Have been looking for a good tutorial on this for sooooo long!
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
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.
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^^.
I need help, the portal is flipped upside down. Even when i flip the camera 180 on the x axis, nothing happens
Thank you so much, now I have a solid game!
Hello abjourn, I would just Like to thank you for all your help! You are the best programming tutor in the world!
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.
James Heazlewood use LateUpdate() instead of update .
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.
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.
Works fine for me, using version 2018.3.10f1
Render Textures and Shaders are super powerful elements, please do a video explaining how they work!
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 :)
put annother plane just behind the portal, put a box colider on it and don't click on "is trigger" and disable mesh renderer ;)
yes I will do this if brackeys dont fix this
You are a genius. That quaterinion stuff code was marvelous.
Thank you!
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;
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!!!
excuse me, this code will be added to Player Object, right ?
That's Antichamber in a Nutshell. well done. I appreciate all the video you're making.
For the people who can't download that shader from description link
drive.google.com/file/d/1P3HSi7alDGttF9R98xDW7OhtswLO1FHm/view?usp=sharing
Thank you so much. I was looking for something like this.
a hero
actual legend
a year later and still a hero
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.
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?
Hi! I’ve been having the same issue… we’re you able to fix this somehow?
@@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.
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.
What if I want to have a different rotation on each portal? this only works if both have the same rotation.
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.
Love your tutorials😍 I watch at least one video in a day. Keep it on Brackeys
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?
BM.G Games - Mobile Games Great Idea hope he does it :)
Yassssssss
cannot be more thankful
For rotation can’t we do transform.rotation = firstcamera.transform.rotation ?
What if your portals are angled differently?
Benedani You have a point, but I think in this situation what he suggested might work.
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.
thanks for hauling me through my game production course
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!
Yes please have a series on shader writing!
should give credit ruclips.net/video/iHqjscifPnI/видео.html since its the exact same layout and everything
Look in the description.
Creepiable he added that after I posted this , as I already checked before I posted
The same~OMG
@@tippinggame2799 is brackeys a fraud lol? :)
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
unable to download shaders
You can not believe in how good time you did this video
Why is the depth 24?
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.
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
is it just me or did this not work even tho i tried a million times and did exactly what he said? Just Me.
me too =))
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...
Does anyone know how to solve inconsistent collision detection? As it works but the colliders don't always register it.
Im wondering the same, mine works sometimes and then other times it doesnt :(
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
@@phairz1168 Tried that, it kinda worked more consistently but still consistently doesnt
@@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
@@phairz1168 thanks ill give it a go :)
You win the internets of the decade!
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
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 )
Make a tutorial how to get your game on a phone
Thomas N3K has a very nice tutorial on it
File > Build Settings > Then Switch Platform to Android/iOS. You'll need to install a few things, but then it'll run.
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.
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
*+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.
I would definately love to watch you explain shaders
“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...
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).
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.
if its confusing you can read: en.wikipedia.org/wiki/Slerp#Quaternion_Slerp
ALL HAIL BRACKEYS let his vedios live forever
Brackeys: it doesn't have to be perfect
Also Brackeys: proceeds to make it perfect
That’s so cool dude I’m definitely gonna try that
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.
I just wanted to know how to teleport but I found something more. Great Brakeys.