If anyone is having an issue with their door opening only to one side regardless of what direction you are facing, and you want it to open to the other side (like in the video), check what axis the door is facing. In the video, he has his door facing the X-axis, so in Door.cs, in Awake( ) there is a variable called "Forward" which he defines as "transform.right". If your door is facing the x-axis, then this would work with no issue. If you wanted to have the door face the Z-axis, then you need to change this to "transform.forward". The reason is, when the door is facing the X-axis, the hinge is facing "forward" towards the z-axis, so you would want your dot projecting to the right of that (the x-axis) as that is the axis you are walking through. If though you wanted to walk through a door facing the Z-axis, where your hinge is facing "forward" towards the x-axis, then you want your dot projecting forward, or on the Z-axis. Simply put, if you are having issues with it opening only in one direction regardless of which side of the door you're on, simply find out what axis your door is facing, then put "transform.right" for a door facing the X-axis, or "transform.forward" for a door facing the Z-axis.
Thanks for writing it up 🙂 In the video I talk about this around 5:00 and how to set up the pivot to help with that around 10:45 in the video. I can see that I could have elaborated more on that explanation to be more clear. I appreciate you writing it clearly here!
I haven't been able to watch many videos lately because of work, but hearing your intro made me instantly relax. "You! Yes, you!" It's great! Just wanted to say thanks for this and thanks for another awesome tutorial!
Thank you for this! I was searching for a tutorial on how to make doors open via a players input, and you hit it right on the nail! Keep up the awesome work Chris!
hey grat tutorial but i get error CS0131 wich is The left-hand side of an assignment must be a varieable, property or indexer o ur line of code 47 at minute 9:58 how can i solve this?
Hmm... Double check what you wrote versus what I put there. Maybe you missed the = sign after the UseText.transform.position. If all else fails, you can compare directly to the GitHub code: github.com/llamacademy/doors that has the full project available at the end state of the tutorial (including any fixes mentioned in the description)
@@LlamAcademy I dont seem to be able to select an edge and im very confused as to why. I have pro builder installed and tapped on the edge tool. It just didnt let me. I dont know
@@philipko0068 Only other ideas I can come up with are maybe your object is not a "ProBuilder" object. If it's a normal 3d model you can "Probuilderize" the 3d model so you can set the pivot with ProBuilder
Not sure if you are still answering questions here, but I am having an issue and I am sure I have all the steps down. But after doing the "Player Actions" script, I got a compile error Unity itself saying "Assets\Scripts\Player Actions.cs(8,13): error CS0246: The type or namespace name 'TextMeshPro' could not be found (are you missing a using directive or an assembly reference?)" I am not sure what I did wrong. I did notice that when I made the code, I didn't have TextMeshPro active. But then I got that running and I thought it would help, but I still am running into this same issue.
Hi 👋! When you install the TextMeshPro package it should automatically update your code so it will be able to find that and get rid of the error. If you have other compilation errors other than ones related to TextMeshPro not being found, that can prevent this process from working. When all else fails, I close Unity and start it again and that usually forces it to fix the csproj files and it can resolve those references! Hope that helps!
i recently found this video, and made a door that isnt just a cube. (i used around 4 different objects in total) the text shows up, but it clips with the door, and when i press "e" it doesent open, im sure that i did everything correctly tho
To make the text not appear to clip through the door, you would need to either inspect your object setup a little and ensure the displacement from the hit point (the door collider) is enough to offset from the door model. Alternatively you can ensure your TextMeshPro material is the "Overlay" variant, not the "Distance Field" or "Bitmap". The Overlay ensures it is always rendered on top of the 3d space objects. For why the door won't rotate or slide open, you need to make sure you're rotating/sliding the root transform for the door and that transform has the appropriate pivot. Otherwise it will not work correctly.
This is a super awesome vid, but I've been working on this for a few days now and have had no luck. For starters, when I use the ProBuilder I cant make the pivot stick. I followed the video step by step and it always seems to not rotate every time I create a edge Loop and then press set pivot. It always stays solid and does not rotate in any direction or it turns with in itself and makes a huge mess causing me to start over. As well the door does not respond to me upon pressing E. Secondly the TextMeshPro is all sorts of messed up. Every time I add my player script and create a 3d object with the text mesh and do everything he does in the video, yet the text does not pop up in front of my player whenever I walk up to the door. I feel like im missing something but he just goes over it so fast in the video. I know this is a lot, but I've spent days playing with this tut and have made little to no progress. I would appreciate it a lot if someone could throw me a bone or point me in a new direction. Thanks a lot.
For the pivot, make sure you have only that one edge selected. When you first insert the edge loop it selects 4 edges so setting the pivot won’t work correctly until you select only one. To keep TextMeshPro on top of everything, make sure it’s on the TextMeshPro “Overlay” material and make sure you’re using the TextMeshPro object, NOT the TextMesh object! Hopefully those help!
Hi thank you really for making such a helpful tutorial! I need help with an issue. I'm keen on adding just the auto sliding doors in my game but when I tested it, the IsOpen seem to only be able to turn on just once and the doors never went back to false state. The DoorTrigger script I've not modified and I'm also using a probuild trigger object similar to what you have. Any ideas why?
Hmm that's strange. I would first compare your scene setup to what is available on the github repo: github.com/llamacademy/doors If that all looks good, you can debug or even put Debug.Log("On Trigger Exit") on the DoorTrigger OnTriggerExit to verify that is/is not getting called. If it's not getting called, there's something weird with the trigger / player setup. If it is then you can further debug to see the state of the door to see why it's not closing properly. I hope that helps you track down the issue!
I have a problem. When i use input system, then it's just like... no actiond. Like for example "use", then in that "Behavior" part, it's not shownig me the "On use". will someone help?(and i made the player the same as he haves it) Edit: i fixed it Edit 2: I made my doors open.. but in a very strange way. It should open ONLY in z axis, but it opens in x axis too
Thanks for the tutorial! Sadly I cant make it work. (Im on Unity 2021.3.7f1 Personal) First, when I set "private LayerMask UseLayers;" in the PlayerActions script, I got an error "The name 'Uselayers' does not exist in the current context", so I just renamed "UseLayers" to "Uselayers" and the error disappeared. Then I added the PlayerActions script to the PlayerCapsule, added the references (use text and main camera) and set Uselayers (its shown as Uselayers, not as Use Layers like in Your video, but it has all the options mentioned [Nothing, Everythin, .. , Usable, Player] to Usable. But when I hit Play to check it out, no text appears when I approach the door and it doesnt move when I press E. There are no errors shown in the console or anything. I added the layers usable and player by edit -> project settings -> Tags and Layers -> Layers and then just chose User Layer 7 and put in Usable and User Layer 8 as Player. I dont know what to do :d btw what do You mean when saying "the doors are also on the usable layer" ? :d
Hey 👋! You got that error because the name of “Uselayers” and “UseLayers” is not the same. Notice the second one has a capital L. If you set up the Layer Mask to only use the Usable layer and did not change the Door to be on that Layer (top right of the inspector with the door selected) this will not work because the Raycast will not collide with the door.
Hi there, my door doesn't seem to open. The only changes I made were the following: Instead of using OnUse function I used, in update, the input.getKey method The raycast doesnt seem to be shooting and I don't know why. What is the problem? Why is the raycast not shooting?
Thank you very much! It saved the day :-) ONE URGENT QUESTION: How can I prevent the opening doors from pushing away the player? Shall I rather use animations??
If your dot product calculation is working properly, it should never push the player out of the way because the door will open away from the player. If you have a networked game with multiple players then it becomes more tricky and I think most networked games still have that problem.\
I am unable to get the door to rotate properly, I am not sure if it's because I'm on a different version of unity which is 2022.3.7f1 but I do it exactly the same and it doesn't seem to work :(
The version of Unity shouldn't affect you here. There's another comment here that might help you out that talks about how to use a transform.forward of the door instead of what I did here if your door is oriented differently than mine.
what if I want to add sounds like when you open it will play the open sound and when you close (rotating back to zero) play close sound.. and in sliding door, when it starts coroutine the sound should play. can you give some addvise?
@@LlamAcademy Actualy I made it after I wrote you. For who needs the same, I added these methods: private void PlaySound(AudioClip audioClip, Vector3 position, float volumeMultiplier = 1f) { AudioSource.PlayClipAtPoint(audioClip, position, volumeMultiplier * volume); } private void PlaySound(AudioClip[] audioClipArray, Vector3 position, float volume = 1f) { PlaySound(audioClipArray[Random.Range(0, audioClipArray.Length)], position, volume); } and added some variables: [Header("Sound Configs")] [SerializeField] private AudioClip openSound; [SerializeField] private AudioClip closeSound; [SerializeField] private AudioClip pushingSound; [SerializeField] private AudioClip unlockSound; [SerializeField] private AudioClip lockSound; [SerializeField] private AudioClip[] creakSound; I added "PlaySound(openSound, transform.position);" in DoRotationOpen() beginning and DoRotationClose() ending. Also I made for creakSounds too, but now, I am not going to mention on that. Now I want to ask you about key for the doors. For intance, I have 4 same key, but for differents door and I want every each key will unlock only whose index (it's integer variable) fits. How will I do this? (I try to made it with an intex variable but maybe you can do it in better way)
The door trigger is simply a collider marked with “Is Trigger” true and has the DoorTrigger script. It can be any collider. In this case I have used a ProBuilder cube and click “Make Trigger” in the ProBuilder window
Which input system you’re using shouldn’t impact that. If you check out the project on GitHub and compare what you have to what’s there, maybe you can spot a subtle difference between the two?
@@LlamAcademy I couldn't find any diffrences between our code. the door will close just fine and it will open just fine but it only opens in one direction, when I check the debug log for the dot it says it's zero. so I know that the issue should be in the dot variable itself, but like I said before our code is the same.
@@buried935 easiest way I can say to figure out what is happening is to Debug.Log the dot product value and see how that compares to what we’re checking against here. That may shed light on what’s going on
@@LlamAcademy so the UserPosition variable was getting the doors transform.position and subtracting it from itself, thats why it came out to zero. so I just set the UserPosition variable to get the Player object position before passing it into the dot. this has fixed my problem.
So super Unity noob question...How did you add the StarterAssets (Input Action Asset) as a tab? Just trying to get to the point of defining the "use" action .
Hii! Ii have been following the steps on the video, and so far, there have been no errors on the console- however, I can't seem to be able to select "Usable" on the Use Layers from the Player Actions Script, which, I'm guessing is the reason the doors will not open when pressing "E" :( Is there any way to solve this? I'm new to Unity. Thanks!!
Hi! Welcome! That’s a great question! I did not cover that part in the video. You will have to set up the physics layers in Edit > Project Settings > Tags and Layers > add a new Usable layer and a Player layer here. Then you can put the door on Usable and the player on the Player layer!
Maybe you are using URP or HDRP? I believe this was done with built-in render pipeline. You may need to run the material conversion process, or if you’re just looking, open it with built in render pipeline
Hey thanks for making this tutorial! I'm trying to implement this for multiple sliding doors that all are rotated differently on the Y-axis. I'm using a raycast to find the door and using the out hit to define in the coroutine the gameobject I would like to slide. The problem I'm having is if one door is open, the isOpen bool is true. So if I try to open another door it thinks it needs to close. How would I be able to adapt it for this situation? Thanks for any help!
Hi! What you described sounds like you are maybe unintentionally reusing a Door reference across multiple different doors. The "isOpen" status of one door should not impact any other door. Double check that and hopefully that can resolve your problem!
Thanks for the quick response! That was exactly what the problem was! I didn't know how to access only the script of the specific door I was interacting with, but then I figured it out and now I know how to do it! @@LlamAcademy
Hey, I'm trying to see how this code works in a project and I'm not sure I know how you got your input system to work. Do I create a new variable or what? Still new to unity so if I said something infuriating I apologize. Edit: Found out I have to use the new input system to make it work, nevermind.
We start out the text disabled so the player doesn't see it. Then instead of Instantiating and Destroying it when the player looks/stops looking at a door at a door, we just place it where the player is looking and enable it!
I have a problem, When I am facing the door and open it it opens but when I open it from the other side it keeps opening but twards me. I am using a door I made myself.
Hi! Please check your code versus what is in the GitHub repository: github.com/llamacademy/doors After posting this I noticed a small error in the math (see below information from description) that may be causing your issue: if (ForwardAmount >= ForwardDirection) { endRotation = Quaternion.Euler(new Vector3(0, StartRotation.y + RotationAmount, 0)); } else { endRotation = Quaternion.Euler(new Vector3(0, StartRotation.y - RotationAmount, 0)); } If you've combed over both of those and still have that error let me know!
I'm having some trouble when I rotate the door 90 degrees to use it in another wall, because now it opens 180 degrees one way, and when I'm on the other side and close the door, I can't open it again.. Something gets messed up with the dot it seems like..
There was a slight math problem in this video that has since been corrected on the GitHub and I updated the description of the video with that small change. Can you double check what you have against that and see if that helps? github.com/llamacademy/doors
Yes! You can do that and just have a reference to the door on your "switch" and when the user clicks, presses E, or whatever then you can just call Door.Open() or Door.Close() like the DoorTrigger does in this video.
Thanks I now stuck with the ui not rotating when I use a door a different way to the one I started with ie I move the door 90 degrees to fit another building but the ui dot rotate
Alright I'm getting an issue that is probably just a major oversight on my end but I'm getting a NullReferenceException error with this line of code if (hit.collider.TryGetComponent(out Door door)) I was wondering what the cause/a solution would be?
Hmm I’m not sure how you can have that using this code. Did you maybe not check if the Raycast made contact before trying to use the RacastHit (“hit” above)? In that case I could see “collider” being null and giving you a NullReferenceException.
Hello Amazing Tutorial, However i have an issue. the sliding is working, but the door does not return to it's exact last position. onClose the door keep leaving a space and does not close completely. do you know what might be the issue?
Hmm… you know what. On open and close Coroutines, after the loop we don’t assign the final transform position / rotation. That can leave small gaps in closing, especially at lower frame rates.
The doors open and close perfectly, But the sliding doors to not slide. If I change them to rotating they work, so the triggers are working. But both sliding doors as sliding doors are not moving. I even used your script i downloaded and its the same result. What am I doing wrong? Using UNITY 2021
Hmm hard to tell from just that. If you download the whole project and run it do you get the same issue? It could be something like the doors are marked static, or maybe the slide amount is too small relative to the door size
@@LlamAcademy Yes, tried that. Tried running the original project and same issue. Its weird. It works if I click rotation. The sliding doors will rotate. But not slide. Is there a way I can have it trigger an animation controller instead?
Hi, I don't know if you are still replying. I have followed every step I can in this tut, but my text always shows up at the same position outside of the camera frame, and when I press "e" nothing happens. do you have any idea why that happens? thank you!
That sounds like maybe a physics layer configuration issue or raycasting issue. Don't forget the full project is on GitHub: github.com/llamacademy/doors so you can check it out and compare what you have versus what I have, and/or just take the door script from there directly!
For that you can use a Coroutine to wait some time after the door opens and just close it after the delay. If the door is opened again before that happens you’d want to stop that Coroutine so you don’t have it close too quick
I am making a map for my first person low poly tactical shooter. If I add this feature how do I make it work for every door in the game? Do I have to program this to every single door.
I set up your rotating door, and it opens away from my player nicely. However, when it rotates open, it doesn't rotate the full 90 degrees. It gets to somewhere like 88.7 degrees, and then it gets farther and farther off, returning from 88.7 degrees to 3 degrees, etc. How can I fix this? Many thanks
Hmm... It might be that after the Lerp in DoRotationOpen (and DoSlidingOpen may have the same problem) you need to do one last assignment of the rotation to the target rotation and target positions repsectively.
@@LlamAcademy That fixed it! Thanks so very much. To improve functionality, I also modified the arguments surrounding your RotationAmount. Now, I can input X, Y, or Z rotation amounts and the axis of rotation directly. And I got rid of the ForwardDirection variable. Maybe that caused the now-fixed problem, but now I have greater functionality. (I did the same for sliding by making SlideAmount a Vector3, and cutting SlideDirection, since inputting a - value into SlideAmount tells it the direction already.) Thanks again! private IEnumerator DoRotationOpen(float ForwardAmount) { Quaternion startRotation = transform.rotation; Quaternion endRotation; if (ForwardAmount > 0) { endRotation = Quaternion.Euler(StartRotation + RotationAmount); } else { endRotation = Quaternion.Euler(StartRotation - RotationAmount); } IsOpen = true; float time = 0; while (time < 1) { transform.rotation = Quaternion.Lerp(startRotation, endRotation, time); yield return null; time += Time.deltaTime * Speed; transform.rotation = endRotation; }
Hmm...did you check the "IsOpen" is set correctly on the door that's showing up wrong? You may consider making a new door fresh instead of copy/pasting it to see if that also helps.
@@LlamAcademy Ok so a few restarts got the OnUse problem solved, but then i got his with "You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings." due to just slapping all of the tutorial onto my current project. Was able to fix that under player configurations and DOOR OPENS NOW LES GO
Would this script also work in case I was creating a simulation in VR? Maybe instead of the E key, I replace it with the Grip or Trigger from the Quest 2 Controller.
I haven't specifically worked with VR, but I don't see any reason this shouldn't work. This is just Transform manipulation which should work regardless of the rendering target.
Okay. The only thing is I'd have to change the Player Input. Which in your case is activated if I press E. Instead, since I have the Input Action from the XR Interaction Toolkit, I have to change the key. ;)
This is the default ProBuilder material. You can get that from the package manager. With the UVs on ProBuilder objects, it's perfectly aligned to 1 meter.
This is pretty nice. My main issue is getting the door to open in a straight line when I rotate the object. I'm making tables that have tops that slide off and when I move them somewhere else and rotate them the door slides diagonally. Is there a fix for this
Sure! Remember once you rotate something the directionality of the X,Y, and Z changes. So if you’re planning to pair these rotations and movements you might have to change also the direction you plan to slide something. Another option could be to rotate a child object and move the parent. So you might have 2 “doors”, one that slides to open and one that rotates where the rotating one is a child of the sliding one
@@LlamAcademy I did figure it out, but my main issue with it is that rather than just simply sending it to a specific coordinate the way this script works is it sends it out. I might be able to figure out how to do it the way I want, but I'm not sure. I'm definitely using something like this in a game I'm working on because this is absolutely amazing other than that issue I have
great video but how do I access the input action without the starter assets package i'm not sure if you will respond but maybe someone from the comments will
Make sure you have ProBuilder in your project, have added an edge loop in the middle of the door and selected the particular edge you want to set the pivot of. If you have the GameObject selection mode then it will just center the pivot at the center of the door
Absolutely! The starter assets used here are just for an out of the box character controller. We are in no way attached to that controller system for the doors in the video
i dunno if people are still gonna be responding to this however, i followed along to the video and downloaded the code from github and i keep getting an error message saying "The namespace already contains a definition for 'Door' " and im not sure what that means? im realitively new to unity so this is a bit confusing
It sounds like you already have a “Door” script in your project. Since this project also has a “Door” script, it’s telling you that you have a duplicate and it can’t tell which one should be used
This repository isn’t meant to be dropped in on top of one of your existing projects in full because it includes things like the first person movement package. It seems like you already have that package and maybe dumped this one inside your project and that’s causing errors. The BasicRigidbodyPush is included in that first person controller package so that’s my guess on what happened here.
@@LlamAcademy thank you so much for the fast responses lmao- i think i fixed that as well. the last error i got (hopefully) says "ScriptableSingleton already exists. Did you query the singleton in a constructor?"
Hey Great Tutorial!! Is It possible to add a handle? So that the player has to look at the handle and press [E] for the door to open I'd appreciate the help
Conceptually you’d do something like door trigger where it would have a reference to the door itself, and handle showing the text not when you hit a door, but when you hit a door handle
As long as your door has the correct pivot it's the same process. You'll have to check how to set the pivot in your preferred 3d modeling program to do that though
You'd follow the same process more or less, using a tap to raycast or a virtual button instead of the E button press. The auto opening ones will behave the same!
This is why I set the sliding door amount to less than the size of the door, so a nub of the door sticks out some for the player to still be able to close it. Check the slide amount you have set on the sliding door
Couldn't you have maybe split up the code for sliding and rotating doors as its incredibly inconvenient to look at all the stuff for rotating doors when I want to make a sliding door.
Hi! I did split up the code as much as possible by having separate sections in the video and Coroutine functions to handle the Slide versus Rotate to open and had explicit conditionals around them. If in your project you only need sliding doors, you can safely remove anything to do with the rotation and it will still function perfectly 👌!
@@LlamAcademy yeah i have the same issue even when i copied and pasted the code it said its a namespace error im pretty sure the line was"private Door Door;"
@@LlamAcademy im not sure if this helps, but im using unity's built in 1st person template and its given me trouble in the past so i guess id just let you know
@@LlamAcademy 2020.3.30f1. I'm using the same starter assets pack from unity- the 1st person mode with cinemachine. The doors, after initially opening, rather than close on 'use,' they swing open the opposite direction. Also, the text doesn't show in the right place.
The door problem sounds like maybe the "IsOpen" bool is not set after you open it, so it tries to open in the other direction. Double check that when you open the door IsOpen is set to true, and when closing, IsOpen is set to false. I downloaded the project fresh and the rotating doors were working correctly. The door text by default when you import TextMeshPro will intersect the door. You can easily fix this by updating the material to the "Overlay" Text Mesh Pro shader instead of the "Distance Field" one
Hi! I've followed the script through but for some reason, when applying these scripts, the doors in question become invisible? When removing the script they still remain invisible too. I don't quite understand how it has happened, do you know what could have caused a bizarre error? Thanks in advance, dude! : ]
That's pretty weird! I can't think of why they would disappear. We're not adjusting the materials or shaders at all. Can you check if they got moved to a strange location by checking the scene view?
@@LlamAcademy Scene view shows as normal. It's a very bizarre issue and I cannot think why. Just to narrow it down, I have added the scripts for manual activating doors. Both slide and rotation. I will try the automatic to see if that creates anything further. No materials have been added to the normal doors but I did use pre built doors, although, I can't think why that would cause the issue. The sliding door I created, similar to your doors and I have made them transparent but that wouldn't be the cause for any of them. The activation doesn't happen either. I will have a play around and see what could be causing it.
It happens after changing the layer to "usable" for me. I fixed the issue by going to the main camera > culling mask, and selecting the "usable" layer from the drop down menu.
If anyone is having an issue with their door opening only to one side regardless of what direction you are facing, and you want it to open to the other side (like in the video), check what axis the door is facing.
In the video, he has his door facing the X-axis, so in Door.cs, in Awake( ) there is a variable called "Forward" which he defines as "transform.right". If your door is facing the x-axis, then this would work with no issue. If you wanted to have the door face the Z-axis, then you need to change this to "transform.forward".
The reason is, when the door is facing the X-axis, the hinge is facing "forward" towards the z-axis, so you would want your dot projecting to the right of that (the x-axis) as that is the axis you are walking through.
If though you wanted to walk through a door facing the Z-axis, where your hinge is facing "forward" towards the x-axis, then you want your dot projecting forward, or on the Z-axis.
Simply put, if you are having issues with it opening only in one direction regardless of which side of the door you're on, simply find out what axis your door is facing, then put "transform.right" for a door facing the X-axis, or "transform.forward" for a door facing the Z-axis.
Thanks for writing it up 🙂 In the video I talk about this around 5:00 and how to set up the pivot to help with that around 10:45 in the video. I can see that I could have elaborated more on that explanation to be more clear. I appreciate you writing it clearly here!
@@LlamAcademy pivot is a must!
I haven't been able to watch many videos lately because of work, but hearing your intro made me instantly relax. "You! Yes, you!" It's great! Just wanted to say thanks for this and thanks for another awesome tutorial!
😄 Great to hear you're back watching!
Thank you for this! I was searching for a tutorial on how to make doors open via a players input, and you hit it right on the nail! Keep up the awesome work Chris!
That's awesome to hear!
You rock it man. I was going MAD about how to implement math's normal vector concept on this. Tysm!!
this is extremely important, as most games need to deal with ports, and this is a nice tutorial on how to do that.
I couldn't agree more 🙂!
Thanks for your awesome Unity AI tutorials! They've been a huge help and really stand out. Keep up the great work Chris! 🙏
This tutorial is perfect! I was just looking to get into adding functionality to the doors in my current project.
Awesome!
how come in 2:47 there was no "use in control scheme" for me?
Great stuff! Thanks for making these videos, they're excellent!
Thank you!
Nice tutorial and awesome RUclipsr! Fast response to questions even on older videos!
hey grat tutorial but i get error CS0131 wich is The left-hand side of an assignment must be a varieable, property or indexer o ur line of code 47 at minute 9:58 how can i solve this?
Hmm... Double check what you wrote versus what I put there. Maybe you missed the = sign after the UseText.transform.position. If all else fails, you can compare directly to the GitHub code: github.com/llamacademy/doors that has the full project available at the end state of the tutorial (including any fixes mentioned in the description)
Thanks so much! All-in-one, perfect door system.
Perfect Tutorial 🙅🧢
thank you. that helped me a lot with my door
Hi, my door opens but also tilts 90deg in the z axis, so its open but on its side. Please help
I dont know if you are gonna respond but at 11:36 this option is locked out for me and i have no idea why.
Usually that option is disabled if you have not yet selected the edge you want to set as the pivot
@@LlamAcademy I dont seem to be able to select an edge and im very confused as to why. I have pro builder installed and tapped on the edge tool. It just didnt let me. I dont know
@@philipko0068 Only other ideas I can come up with are maybe your object is not a "ProBuilder" object. If it's a normal 3d model you can "Probuilderize" the 3d model so you can set the pivot with ProBuilder
This is exactly what I needed, thank you so much!!
You’re welcome! 🙌
as always ... awesome!
Not sure if you are still answering questions here, but I am having an issue and I am sure I have all the steps down.
But after doing the "Player Actions" script, I got a compile error Unity itself saying "Assets\Scripts\Player Actions.cs(8,13): error CS0246: The type or namespace name 'TextMeshPro' could not be found (are you missing a using directive or an assembly reference?)"
I am not sure what I did wrong. I did notice that when I made the code, I didn't have TextMeshPro active. But then I got that running and I thought it would help, but I still am running into this same issue.
Hi 👋! When you install the TextMeshPro package it should automatically update your code so it will be able to find that and get rid of the error. If you have other compilation errors other than ones related to TextMeshPro not being found, that can prevent this process from working.
When all else fails, I close Unity and start it again and that usually forces it to fix the csproj files and it can resolve those references! Hope that helps!
i recently found this video, and made a door that isnt just a cube. (i used around 4 different objects in total) the text shows up, but it clips with the door, and when i press "e" it doesent open, im sure that i did everything correctly tho
To make the text not appear to clip through the door, you would need to either inspect your object setup a little and ensure the displacement from the hit point (the door collider) is enough to offset from the door model. Alternatively you can ensure your TextMeshPro material is the "Overlay" variant, not the "Distance Field" or "Bitmap". The Overlay ensures it is always rendered on top of the 3d space objects.
For why the door won't rotate or slide open, you need to make sure you're rotating/sliding the root transform for the door and that transform has the appropriate pivot. Otherwise it will not work correctly.
alright, thanks for the help! i'll try it right now!
Hey man, i would like to know, how could i define pivot in code (if it's even possible) please ?
Not sure. Would have to do some googling to find out
This is a super awesome vid, but I've been working on this for a few days now and have had no luck.
For starters, when I use the ProBuilder I cant make the pivot stick. I followed the video step by step and it always seems to not rotate every time I create a edge Loop and then press set pivot. It always stays solid and does not rotate in any direction or it turns with in itself and makes a huge mess causing me to start over. As well the door does not respond to me upon pressing E.
Secondly the TextMeshPro is all sorts of messed up. Every time I add my player script and create a 3d object with the text mesh and do everything he does in the video, yet the text does not pop up in front of my player whenever I walk up to the door. I feel like im missing something but he just goes over it so fast in the video.
I know this is a lot, but I've spent days playing with this tut and have made little to no progress. I would appreciate it a lot if someone could throw me a bone or point me in a new direction. Thanks a lot.
For the pivot, make sure you have only that one edge selected. When you first insert the edge loop it selects 4 edges so setting the pivot won’t work correctly until you select only one.
To keep TextMeshPro on top of everything, make sure it’s on the TextMeshPro “Overlay” material and make sure you’re using the TextMeshPro object, NOT the TextMesh object! Hopefully those help!
Hi thank you really for making such a helpful tutorial! I need help with an issue. I'm keen on adding just the auto sliding doors in my game but when I tested it, the IsOpen seem to only be able to turn on just once and the doors never went back to false state. The DoorTrigger script I've not modified and I'm also using a probuild trigger object similar to what you have. Any ideas why?
Hmm that's strange. I would first compare your scene setup to what is available on the github repo: github.com/llamacademy/doors
If that all looks good, you can debug or even put Debug.Log("On Trigger Exit") on the DoorTrigger OnTriggerExit to verify that is/is not getting called. If it's not getting called, there's something weird with the trigger / player setup. If it is then you can further debug to see the state of the door to see why it's not closing properly.
I hope that helps you track down the issue!
Opening ordinary doors are fine , but a turnstyle type door is tricky
I have a problem. When i use input system, then it's just like... no actiond. Like for example "use", then in that "Behavior" part, it's not shownig me the "On use". will someone help?(and i made the player the same as he haves it)
Edit: i fixed it
Edit 2: I made my doors open.. but in a very strange way. It should open ONLY in z axis, but it opens in x axis too
Glad you got it fixed!
THANK YOU SO MUCH MAN YOU'RE A LIFESAVER!!!!!!!!!!!!
Awesome Tutorial!!
Thanks for the tutorial! Sadly I cant make it work. (Im on Unity 2021.3.7f1 Personal)
First, when I set "private LayerMask UseLayers;" in the PlayerActions script, I got an error "The name 'Uselayers' does not exist in the current context", so I just renamed "UseLayers" to "Uselayers" and the error disappeared.
Then I added the PlayerActions script to the PlayerCapsule, added the references (use text and main camera) and set Uselayers (its shown as Uselayers, not as Use Layers like in Your video, but it has all the options mentioned [Nothing, Everythin, .. , Usable, Player] to Usable.
But when I hit Play to check it out, no text appears when I approach the door and it doesnt move when I press E. There are no errors shown in the console or anything.
I added the layers usable and player by edit -> project settings -> Tags and Layers -> Layers and then just chose User Layer 7 and put in Usable and User Layer 8 as Player.
I dont know what to do :d
btw what do You mean when saying "the doors are also on the usable layer" ? :d
Hey 👋! You got that error because the name of “Uselayers” and “UseLayers” is not the same. Notice the second one has a capital L.
If you set up the Layer Mask to only use the Usable layer and did not change the Door to be on that Layer (top right of the inspector with the door selected) this will not work because the Raycast will not collide with the door.
@@LlamAcademy omg it works now. Thanks a lot for Your help!
Hi there,
my door doesn't seem to open. The only changes I made were the following:
Instead of using OnUse function I used, in update, the input.getKey method
The raycast doesnt seem to be shooting and I don't know why. What is the problem? Why is the raycast not shooting?
Hey , I want to make a drawer with the new input system but having a lot of issues . Could you make a tutorial of it?
A drawer is basically the same thing as a sliding door 🙂
@@LlamAcademy Thank you soooo much. your the best youtuber i have ever seen 😃
@@LlamAcademy And also can you tell me how to make locks? sorry for disturbing can't find any tutorial about it.
Thank you very much! It saved the day :-) ONE URGENT QUESTION: How can I prevent the opening doors from pushing away the player? Shall I rather use animations??
If your dot product calculation is working properly, it should never push the player out of the way because the door will open away from the player.
If you have a networked game with multiple players then it becomes more tricky and I think most networked games still have that problem.\
I am unable to get the door to rotate properly, I am not sure if it's because I'm on a different version of unity which is 2022.3.7f1 but I do it exactly the same and it doesn't seem to work :(
The version of Unity shouldn't affect you here. There's another comment here that might help you out that talks about how to use a transform.forward of the door instead of what I did here if your door is oriented differently than mine.
Thanks a lot sir, this is perfect for my scifi game
what if I want to add sounds like when you open it will play the open sound and when you close (rotating back to zero) play close sound.. and in sliding door, when it starts coroutine the sound should play. can you give some addvise?
You just attach an AudioSource to the Door and [SerializeField] some AudioClips for Open/Close then play a sound with AudioSource.Play(AudioClip)
@@LlamAcademy Actualy I made it after I wrote you. For who needs the same, I added these methods:
private void PlaySound(AudioClip audioClip, Vector3 position, float volumeMultiplier = 1f)
{
AudioSource.PlayClipAtPoint(audioClip, position, volumeMultiplier * volume);
}
private void PlaySound(AudioClip[] audioClipArray, Vector3 position, float volume = 1f)
{
PlaySound(audioClipArray[Random.Range(0, audioClipArray.Length)], position, volume);
}
and added some variables:
[Header("Sound Configs")]
[SerializeField] private AudioClip openSound;
[SerializeField] private AudioClip closeSound;
[SerializeField] private AudioClip pushingSound;
[SerializeField] private AudioClip unlockSound;
[SerializeField] private AudioClip lockSound;
[SerializeField] private AudioClip[] creakSound;
I added "PlaySound(openSound, transform.position);" in DoRotationOpen() beginning and DoRotationClose() ending. Also I made for creakSounds too, but now, I am not going to mention on that. Now I want to ask you about key for the doors. For intance, I have 4 same key, but for differents door and I want every each key will unlock only whose index (it's integer variable) fits. How will I do this? (I try to made it with an intex variable but maybe you can do it in better way)
im a bit confused at the automatically opening doors, how would you make a door trigger? does it come with the script or..?
The door trigger is simply a collider marked with “Is Trigger” true and has the DoorTrigger script. It can be any collider. In this case I have used a ProBuilder cube and click “Make Trigger” in the ProBuilder window
@@LlamAcademy :o thanks!
I cant get the dot var to recognize the players position, Im not sure if it makes a difference but Im not using unity's new input system.
Which input system you’re using shouldn’t impact that. If you check out the project on GitHub and compare what you have to what’s there, maybe you can spot a subtle difference between the two?
@@LlamAcademy I couldn't find any diffrences between our code. the door will close just fine and it will open just fine but it only opens in one direction, when I check the debug log for the dot it says it's zero. so I know that the issue should be in the dot variable itself, but like I said before our code is the same.
@@buried935 easiest way I can say to figure out what is happening is to Debug.Log the dot product value and see how that compares to what we’re checking against here. That may shed light on what’s going on
@@LlamAcademy so the UserPosition variable was getting the doors transform.position and subtracting it from itself, thats why it came out to zero. so I just set the UserPosition variable to get the Player object position before passing it into the dot. this has fixed my problem.
So super Unity noob question...How did you add the StarterAssets (Input Action Asset) as a tab? Just trying to get to the point of defining the "use" action .
Just double click on the "Starter Assets (Input Action Asset)" under the Player Input script! It will open a new panel with that for you.
@@LlamAcademy Of course, lol. Thanks! Awesome tutorials. Keep up the great work! Feel like I'm learning a ton through your channel.
Hii! Ii have been following the steps on the video, and so far, there have been no errors on the console- however, I can't seem to be able to select "Usable" on the Use Layers from the Player Actions Script, which, I'm guessing is the reason the doors will not open when pressing "E" :(
Is there any way to solve this? I'm new to Unity. Thanks!!
Hi! Welcome! That’s a great question! I did not cover that part in the video.
You will have to set up the physics layers in Edit > Project Settings > Tags and Layers > add a new Usable layer and a Player layer here. Then you can put the door on Usable and the player on the Player layer!
Thanks but why is it that when I import the project files the materials are pink?
Maybe you are using URP or HDRP? I believe this was done with built-in render pipeline. You may need to run the material conversion process, or if you’re just looking, open it with built in render pipeline
are you using urp or hdrp for the graphics because it the scene looks good.
This is the built-in render pipeline
@@LlamAcademy ok cool i think i can make it work in urp thanks for the responce and the door tutorial.
Hey thanks for making this tutorial! I'm trying to implement this for multiple sliding doors that all are rotated differently on the Y-axis. I'm using a raycast to find the door and using the out hit to define in the coroutine the gameobject I would like to slide. The problem I'm having is if one door is open, the isOpen bool is true. So if I try to open another door it thinks it needs to close. How would I be able to adapt it for this situation? Thanks for any help!
Hi! What you described sounds like you are maybe unintentionally reusing a Door reference across multiple different doors. The "isOpen" status of one door should not impact any other door. Double check that and hopefully that can resolve your problem!
Thanks for the quick response! That was exactly what the problem was! I didn't know how to access only the script of the specific door I was interacting with, but then I figured it out and now I know how to do it! @@LlamAcademy
Hey, I'm trying to see how this code works in a project and I'm not sure I know how you got your input system to work. Do I create a new variable or what? Still new to unity so if I said something infuriating I apologize.
Edit: Found out I have to use the new input system to make it work, nevermind.
Glad you figured it out!
thanks for the tutorial :-D . I'm a bit confused of what you excactly are doing with the disabled text
We start out the text disabled so the player doesn't see it. Then instead of Instantiating and Destroying it when the player looks/stops looking at a door at a door, we just place it where the player is looking and enable it!
which component you use to make door model ,door frame and surface area ! can tell me this unity package name
10:46 :)
I have a problem, When I am facing the door and open it it opens but when I open it from the other side it keeps opening but twards me. I am using a door I made myself.
Hi! Please check your code versus what is in the GitHub repository: github.com/llamacademy/doors
After posting this I noticed a small error in the math (see below information from description) that may be causing your issue:
if (ForwardAmount >= ForwardDirection)
{
endRotation = Quaternion.Euler(new Vector3(0, StartRotation.y + RotationAmount, 0));
}
else
{
endRotation = Quaternion.Euler(new Vector3(0, StartRotation.y - RotationAmount, 0));
}
If you've combed over both of those and still have that error let me know!
@@LlamAcademy when I enter that code in there is red lines under ForwardAmount & GetType;=
I'm having some trouble when I rotate the door 90 degrees to use it in another wall, because now it opens 180 degrees one way, and when I'm on the other side and close the door, I can't open it again.. Something gets messed up with the dot it seems like..
Or the rotation amount somehow, I'm not really sure..
There was a slight math problem in this video that has since been corrected on the GitHub and I updated the description of the video with that small change. Can you double check what you have against that and see if that helps? github.com/llamacademy/doors
If u add a object as a switch for the door will u use same tag to open like if u go door and click open would that work
Yes! You can do that and just have a reference to the door on your "switch" and when the user clicks, presses E, or whatever then you can just call Door.Open() or Door.Close() like the DoorTrigger does in this video.
Thanks I now stuck with the ui not rotating when I use a door a different way to the one I started with ie I move the door 90 degrees to fit another building but the ui dot rotate
Alright I'm getting an issue that is probably just a major oversight on my end but I'm getting a NullReferenceException error with this line of code
if (hit.collider.TryGetComponent(out Door door))
I was wondering what the cause/a solution would be?
Hmm I’m not sure how you can have that using this code. Did you maybe not check if the Raycast made contact before trying to use the RacastHit (“hit” above)? In that case I could see “collider” being null and giving you a NullReferenceException.
Hello Amazing Tutorial, However i have an issue. the sliding is working, but the door does not return to it's exact last position. onClose the door keep leaving a space and does not close completely. do you know what might be the issue?
Hmm… you know what. On open and close Coroutines, after the loop we don’t assign the final transform position / rotation. That can leave small gaps in closing, especially at lower frame rates.
The doors open and close perfectly, But the sliding doors to not slide. If I change them to rotating they work, so the triggers are working. But both sliding doors as sliding doors are not moving. I even used your script i downloaded and its the same result. What am I doing wrong? Using UNITY 2021
Hmm hard to tell from just that. If you download the whole project and run it do you get the same issue? It could be something like the doors are marked static, or maybe the slide amount is too small relative to the door size
@@LlamAcademy Yes, tried that. Tried running the original project and same issue. Its weird. It works if I click rotation. The sliding doors will rotate. But not slide. Is there a way I can have it trigger an animation controller instead?
Yes you can do it with an Animation instead. If you're using the Animator component, docs.unity3d.com/ScriptReference/Animator.Play.html will work
@@LlamAcademy Awesome thank you!
Hi, I don't know if you are still replying. I have followed every step I can in this tut, but my text always shows up at the same position outside of the camera frame, and when I press "e" nothing happens. do you have any idea why that happens? thank you!
That sounds like maybe a physics layer configuration issue or raycasting issue. Don't forget the full project is on GitHub: github.com/llamacademy/doors so you can check it out and compare what you have versus what I have, and/or just take the door script from there directly!
Thanks for the great tutorial! If i wanted the door to automatically close after a few seconds, how should I do that?
For that you can use a Coroutine to wait some time after the door opens and just close it after the delay. If the door is opened again before that happens you’d want to stop that Coroutine so you don’t have it close too quick
Cool video :) Do you think I can use AnimationCurve in order to shape the timeline of rotation? ;)
Of course!
I am making a map for my first person low poly tactical shooter. If I add this feature how do I make it work for every door in the game? Do I have to program this to every single door.
You just attach the door script to every door you want to be openable!
I set up your rotating door, and it opens away from my player nicely. However, when it rotates open, it doesn't rotate the full 90 degrees. It gets to somewhere like 88.7 degrees, and then it gets farther and farther off, returning from 88.7 degrees to 3 degrees, etc. How can I fix this? Many thanks
Hmm... It might be that after the Lerp in DoRotationOpen (and DoSlidingOpen may have the same problem) you need to do one last assignment of the rotation to the target rotation and target positions repsectively.
@@LlamAcademy That fixed it! Thanks so very much. To improve functionality, I also modified the arguments surrounding your RotationAmount. Now, I can input X, Y, or Z rotation amounts and the axis of rotation directly. And I got rid of the ForwardDirection variable. Maybe that caused the now-fixed problem, but now I have greater functionality. (I did the same for sliding by making SlideAmount a Vector3, and cutting SlideDirection, since inputting a - value into SlideAmount tells it the direction already.) Thanks again!
private IEnumerator DoRotationOpen(float ForwardAmount)
{
Quaternion startRotation = transform.rotation;
Quaternion endRotation;
if (ForwardAmount > 0)
{
endRotation = Quaternion.Euler(StartRotation + RotationAmount);
}
else
{
endRotation = Quaternion.Euler(StartRotation - RotationAmount);
}
IsOpen = true;
float time = 0;
while (time < 1)
{
transform.rotation = Quaternion.Lerp(startRotation, endRotation, time);
yield return null;
time += Time.deltaTime * Speed;
transform.rotation = endRotation;
}
Awesome, thank you for sharing and glad you got it working!
Hi this tutorial is great but i have one problem.
When duplicate the door, text on first one is "Closed" on the other same but is opened
Can you help?
Hmm...did you check the "IsOpen" is set correctly on the door that's showing up wrong? You may consider making a new door fresh instead of copy/pasting it to see if that also helps.
Now I just need a game concept centered around opening and closing doors and I'll be rich! Thanks for sharing!
If you come up with one... keep that a secret so nobody steals it!
What plugins did you use? Great video BTW!!
I think I covered all the packages used within the video starting at 01:50. It's just probuilder and the starter assets
Ok, thank you!
On the PlayerInput component, within the Send Messages behavior “OnUse” is not within “Will SendMessage() to GameObject”, what do
Sorry, I don’t follow your question
@@LlamAcademy 2:52 the “On Use” that you pointed out in the orange box is not there
@@LlamAcademy Ok so a few restarts got the OnUse problem solved, but then i got his with "You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings." due to just slapping all of the tutorial onto my current project. Was able to fix that under player configurations and DOOR OPENS NOW LES GO
Glad you figured it out!
Would this script also work in case I was creating a simulation in VR? Maybe instead of the E key, I replace it with the Grip or Trigger from the Quest 2 Controller.
I haven't specifically worked with VR, but I don't see any reason this shouldn't work. This is just Transform manipulation which should work regardless of the rendering target.
Okay. The only thing is I'd have to change the Player Input. Which in your case is activated if I press E. Instead, since I have the Input Action from the XR Interaction Toolkit, I have to change the key. ;)
heyo! Quick question, how do you make that texture tile so that its perfectly 1 meter throughout all your surfaces
This is the default ProBuilder material. You can get that from the package manager. With the UVs on ProBuilder objects, it's perfectly aligned to 1 meter.
@@LlamAcademy thanks mate :) and thanks for the video
This is pretty nice. My main issue is getting the door to open in a straight line when I rotate the object. I'm making tables that have tops that slide off and when I move them somewhere else and rotate them the door slides diagonally. Is there a fix for this
Sure! Remember once you rotate something the directionality of the X,Y, and Z changes. So if you’re planning to pair these rotations and movements you might have to change also the direction you plan to slide something.
Another option could be to rotate a child object and move the parent. So you might have 2 “doors”, one that slides to open and one that rotates where the rotating one is a child of the sliding one
@@LlamAcademy I did figure it out, but my main issue with it is that rather than just simply sending it to a specific coordinate the way this script works is it sends it out. I might be able to figure out how to do it the way I want, but I'm not sure. I'm definitely using something like this in a game I'm working on because this is absolutely amazing other than that issue I have
great video but how do I access the input action without the starter assets package
i'm not sure if you will respond but maybe someone from the comments will
You can build out your own docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/ActionAssets.html
@@LlamAcademy thx
the pivot in my unity is not working welll im stuck at pivot set i cant make door like you didcan someone help me to fix this problem
Make sure you have ProBuilder in your project, have added an edge loop in the middle of the door and selected the particular edge you want to set the pivot of. If you have the GameObject selection mode then it will just center the pivot at the center of the door
is there a way for sliding door on local pivot?
Can you elaborate on what you mean by that?
@@LlamAcademy I have sliding door angled at x axis but ur script just slide on global axis
thanks for the help
You're welcome! 🙌
Any way to do it without the Starter Assets library?
Absolutely! The starter assets used here are just for an out of the box character controller. We are in no way attached to that controller system for the doors in the video
Is the door trigger an empty game object
It is a collider with Is Trigger marked true
i dunno if people are still gonna be responding to this however, i followed along to the video and downloaded the code from github and i keep getting an error message saying "The namespace already contains a definition for 'Door' " and im not sure what that means? im realitively new to unity so this is a bit confusing
It sounds like you already have a “Door” script in your project. Since this project also has a “Door” script, it’s telling you that you have a duplicate and it can’t tell which one should be used
@@LlamAcademy ohh i see, thank you so much i'll look into that
i checked but now it's saying "The namespace already contains a definition for BasicRigidBodyPush"
This repository isn’t meant to be dropped in on top of one of your existing projects in full because it includes things like the first person movement package. It seems like you already have that package and maybe dumped this one inside your project and that’s causing errors. The BasicRigidbodyPush is included in that first person controller package so that’s my guess on what happened here.
@@LlamAcademy thank you so much for the fast responses lmao- i think i fixed that as well. the last error i got (hopefully) says "ScriptableSingleton already exists. Did you query the singleton in a constructor?"
Hey Great Tutorial!! Is It possible to add a handle? So that the player has to look at the handle and press [E] for the door to open
I'd appreciate the help
Conceptually you’d do something like door trigger where it would have a reference to the door itself, and handle showing the text not when you hit a door, but when you hit a door handle
@@LlamAcademy butt Idk how to do that And I did think of it but i just didn't really see how i could make it happen
door starts open and slidfes depending on where i am looking
Is anyone having issue with the text colliding with the door and make it hard to read?
To be sure the text is always on top you can use the "Overlay" shader from TextMeshPro.
There's a Problem if you Duplicated the Door The Doors don't Open
the use text goes into the walls help
If you use the shader from TextMeshPro with “Overlay” in the name it won’t happen anymore
i have followed this verbatim, yet my doors just don't move at all. Is there a fix for this?
Edit: i was using the old input system
Check what you have versus what is on GitHub! There could be a small error causing it to not work! github.com/llamacademy/doors
@@LlamAcademy my scripts are from the github and I am still having this issue
@@SwampyWitch Did you get it resolved by using the new input system?
@@LlamAcademy yeah
i cant put my text to the use text
Make sure your text is TextMeshPro, not UnityEngine.UI.Text or TextMeshProUGUI (the one that goes on a canvas)!
@@LlamAcademy it is a text mesh pro
@prodbyplayboii Here is the solution sorry for my english
ruclips.net/video/jCaMG8rkAT8/видео.html
THANK YOU
how to use this in real 3d model door
As long as your door has the correct pivot it's the same process. You'll have to check how to set the pivot in your preferred 3d modeling program to do that though
How i open and close door for android🤧
You'd follow the same process more or less, using a tap to raycast or a virtual button instead of the E button press. The auto opening ones will behave the same!
@@LlamAcademy okey thank😍 i try this
Door Rotates and Slides normally but gets stuck in walls and can't close
This is why I set the sliding door amount to less than the size of the door, so a nub of the door sticks out some for the player to still be able to close it. Check the slide amount you have set on the sliding door
@@LlamAcademy It wasn't this, but I rewrote the Closing functions and it worked. Thank you for responding tho ^^
Couldn't you have maybe split up the code for sliding and rotating doors as its incredibly inconvenient to look at all the stuff for rotating doors when I want to make a sliding door.
Hi! I did split up the code as much as possible by having separate sections in the video and Coroutine functions to handle the Slide versus Rotate to open and had explicit conditionals around them.
If in your project you only need sliding doors, you can safely remove anything to do with the rotation and it will still function perfectly 👌!
wow this guy types fast
Good
Thanks!
Door namespace error
The door is not in a namespace in this video. Without any information I can't help you.
@@LlamAcademy yeah i have the same issue even when i copied and pasted the code it said its a namespace error im pretty sure the line was"private Door Door;"
@@eternaldebot4000 Let me check it out fresh off GitHub and see if I can reproduce that issue
@@LlamAcademy im not sure if this helps, but im using unity's built in 1st person template and its given me trouble in the past so i guess id just let you know
This doesn't even work properly and there are errors in the code.
Hi Joe. Could you share which Unity version you are on, if you typed out the code or downloaded the project, and which errors you are getting?
@@LlamAcademy 2020.3.30f1. I'm using the same starter assets pack from unity- the 1st person mode with cinemachine. The doors, after initially opening, rather than close on 'use,' they swing open the opposite direction. Also, the text doesn't show in the right place.
The door problem sounds like maybe the "IsOpen" bool is not set after you open it, so it tries to open in the other direction. Double check that when you open the door IsOpen is set to true, and when closing, IsOpen is set to false. I downloaded the project fresh and the rotating doors were working correctly.
The door text by default when you import TextMeshPro will intersect the door. You can easily fix this by updating the material to the "Overlay" Text Mesh Pro shader instead of the "Distance Field" one
@@LlamAcademy great I'll try these fixes asap
I love u brrrrrrrrro
❤️
DOORS!!
Hi! I've followed the script through but for some reason, when applying these scripts, the doors in question become invisible? When removing the script they still remain invisible too. I don't quite understand how it has happened, do you know what could have caused a bizarre error? Thanks in advance, dude! : ]
That's pretty weird! I can't think of why they would disappear. We're not adjusting the materials or shaders at all. Can you check if they got moved to a strange location by checking the scene view?
@@LlamAcademy Scene view shows as normal. It's a very bizarre issue and I cannot think why. Just to narrow it down, I have added the scripts for manual activating doors. Both slide and rotation. I will try the automatic to see if that creates anything further. No materials have been added to the normal doors but I did use pre built doors, although, I can't think why that would cause the issue. The sliding door I created, similar to your doors and I have made them transparent but that wouldn't be the cause for any of them. The activation doesn't happen either. I will have a play around and see what could be causing it.
It happens after changing the layer to "usable" for me. I fixed the issue by going to the main camera > culling mask, and selecting the "usable" layer from the drop down menu.