Doors in Unity - Sliding and Rotating Doors | Make Them Automatically Open/Close or Usable

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

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

  • @IanZeAlien
    @IanZeAlien Год назад +26

    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.

    • @LlamAcademy
      @LlamAcademy  Год назад +8

      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!

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

      @@LlamAcademy pivot is a must!

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

    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!

    • @LlamAcademy
      @LlamAcademy  3 года назад +2

      😄 Great to hear you're back watching!

  • @nickschnitzer6050
    @nickschnitzer6050 3 года назад +12

    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!

  • @racrity
    @racrity 9 месяцев назад +1

    You rock it man. I was going MAD about how to implement math's normal vector concept on this. Tysm!!

  • @ronigleydsonvilasnovas8067
    @ronigleydsonvilasnovas8067 3 года назад +5

    this is extremely important, as most games need to deal with ports, and this is a nice tutorial on how to do that.

    • @LlamAcademy
      @LlamAcademy  3 года назад +2

      I couldn't agree more 🙂!

  • @alielhefnawey5764
    @alielhefnawey5764 7 месяцев назад +1

    Thanks for your awesome Unity AI tutorials! They've been a huge help and really stand out. Keep up the great work Chris! 🙏

  • @Pandiculate_
    @Pandiculate_ 3 года назад +7

    This tutorial is perfect! I was just looking to get into adding functionality to the doors in my current project.

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

    how come in 2:47 there was no "use in control scheme" for me?

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

    Great stuff! Thanks for making these videos, they're excellent!

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

    Nice tutorial and awesome RUclipsr! Fast response to questions even on older videos!

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

    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?

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

      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)

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

    Thanks so much! All-in-one, perfect door system.

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

    Perfect Tutorial 🙅🧢

  • @ittology-apps
    @ittology-apps Год назад +1

    thank you. that helped me a lot with my door

  • @mrlowfps2008
    @mrlowfps2008 4 месяца назад

    Hi, my door opens but also tilts 90deg in the z axis, so its open but on its side. Please help

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

    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.

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

      Usually that option is disabled if you have not yet selected the edge you want to set as the pivot

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

      @@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

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

      @@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

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

    This is exactly what I needed, thank you so much!!

  • @cyco3oy
    @cyco3oy 3 года назад +2

    as always ... awesome!

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

    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.

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

      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!

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

    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

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

      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.

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

      alright, thanks for the help! i'll try it right now!

  • @misterioness4028
    @misterioness4028 4 месяца назад +1

    Hey man, i would like to know, how could i define pivot in code (if it's even possible) please ?

    • @LlamAcademy
      @LlamAcademy  4 месяца назад

      Not sure. Would have to do some googling to find out

  • @colegregory6408
    @colegregory6408 Год назад +1

    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.

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

      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!

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

    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?

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

      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!

  • @johanolivier3029
    @johanolivier3029 Год назад +1

    Opening ordinary doors are fine , but a turnstyle type door is tricky

  • @dr.albitros4242
    @dr.albitros4242 2 года назад +2

    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

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

    THANK YOU SO MUCH MAN YOU'RE A LIFESAVER!!!!!!!!!!!!

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

    Awesome Tutorial!!

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

    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

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

      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.

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

      @@LlamAcademy omg it works now. Thanks a lot for Your help!

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

    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?

  • @DanRobart
    @DanRobart Год назад +1

    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?

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

      A drawer is basically the same thing as a sliding door 🙂

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

      @@LlamAcademy Thank you soooo much. your the best youtuber i have ever seen 😃

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

      @@LlamAcademy And also can you tell me how to make locks? sorry for disturbing can't find any tutorial about it.

  • @Florijin
    @Florijin 2 месяца назад

    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??

    • @LlamAcademy
      @LlamAcademy  2 месяца назад

      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.\

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

    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 :(

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

      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.

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

    Thanks a lot sir, this is perfect for my scifi game

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

    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
      @LlamAcademy  Год назад

      You just attach an AudioSource to the Door and [SerializeField] some AudioClips for Open/Close then play a sound with AudioSource.Play(AudioClip)

    • @employerslave
      @employerslave Год назад +1

      ​@@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)

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

    im a bit confused at the automatically opening doors, how would you make a door trigger? does it come with the script or..?

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

      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

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

      @@LlamAcademy :o thanks!

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

    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.

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

      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?

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

      @@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.

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

      @@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

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

      @@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.

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

    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 .

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

      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.

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

      @@LlamAcademy Of course, lol. Thanks! Awesome tutorials. Keep up the great work! Feel like I'm learning a ton through your channel.

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

    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!!

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

      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!

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

    Thanks but why is it that when I import the project files the materials are pink?

    • @LlamAcademy
      @LlamAcademy  Год назад +1

      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

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

    are you using urp or hdrp for the graphics because it the scene looks good.

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

      This is the built-in render pipeline

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

      @@LlamAcademy ok cool i think i can make it work in urp thanks for the responce and the door tutorial.

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

    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!

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

      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!

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

      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

  • @symphonyin152mm3
    @symphonyin152mm3 Год назад +1

    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.

  • @ZANEJOHN
    @ZANEJOHN 8 месяцев назад

    thanks for the tutorial :-D . I'm a bit confused of what you excactly are doing with the disabled text

    • @LlamAcademy
      @LlamAcademy  8 месяцев назад

      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!

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

    which component you use to make door model ,door frame and surface area ! can tell me this unity package name

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

    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.

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

      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!

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

      @@LlamAcademy when I enter that code in there is red lines under ForwardAmount & GetType;=

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

    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..

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

      Or the rotation amount somehow, I'm not really sure..

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

      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

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

    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

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

      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.

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

      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

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

    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?

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

      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.

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

    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?

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

      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.

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

    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

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

      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

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

      @@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?

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

      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

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

      @@LlamAcademy Awesome thank you!

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

    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!

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

      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!

  • @Daro-Wolfe
    @Daro-Wolfe Год назад

    Thanks for the great tutorial! If i wanted the door to automatically close after a few seconds, how should I do that?

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

      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

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

    Cool video :) Do you think I can use AnimationCurve in order to shape the timeline of rotation? ;)

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

    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.

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

      You just attach the door script to every door you want to be openable!

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

    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

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

      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.

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

      @@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;
      }

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

      Awesome, thank you for sharing and glad you got it working!

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

    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?

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

      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.

  • @jorbascrumps
    @jorbascrumps 3 года назад +2

    Now I just need a game concept centered around opening and closing doors and I'll be rich! Thanks for sharing!

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

      If you come up with one... keep that a secret so nobody steals it!

  • @Architect-u2g
    @Architect-u2g 10 месяцев назад

    What plugins did you use? Great video BTW!!

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

      I think I covered all the packages used within the video starting at 01:50. It's just probuilder and the starter assets

    • @Architect-u2g
      @Architect-u2g 10 месяцев назад

      Ok, thank you!

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

    On the PlayerInput component, within the Send Messages behavior “OnUse” is not within “Will SendMessage() to GameObject”, what do

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

      Sorry, I don’t follow your question

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

      @@LlamAcademy 2:52 the “On Use” that you pointed out in the orange box is not there

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

      @@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

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

      Glad you figured it out!

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

    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.

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

      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.

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

      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. ;)

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

    heyo! Quick question, how do you make that texture tile so that its perfectly 1 meter throughout all your surfaces

    • @LlamAcademy
      @LlamAcademy  Год назад +1

      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.

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

      @@LlamAcademy thanks mate :) and thanks for the video

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

    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

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

      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

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

      @@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

  • @The_Lorx.
    @The_Lorx. 6 месяцев назад

    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

    • @LlamAcademy
      @LlamAcademy  6 месяцев назад

      You can build out your own docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/ActionAssets.html

    • @The_Lorx.
      @The_Lorx. 6 месяцев назад

      @@LlamAcademy thx

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

    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

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

      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

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

    is there a way for sliding door on local pivot?

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

      Can you elaborate on what you mean by that?

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

      @@LlamAcademy I have sliding door angled at x axis but ur script just slide on global axis

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

    thanks for the help

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

    Any way to do it without the Starter Assets library?

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

      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

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

    Is the door trigger an empty game object

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

      It is a collider with Is Trigger marked true

  • @fxrget-me-not
    @fxrget-me-not 2 года назад

    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

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

      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

    • @fxrget-me-not
      @fxrget-me-not 2 года назад

      @@LlamAcademy ohh i see, thank you so much i'll look into that

    • @fxrget-me-not
      @fxrget-me-not 2 года назад

      i checked but now it's saying "The namespace already contains a definition for BasicRigidBodyPush"

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

      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.

    • @fxrget-me-not
      @fxrget-me-not 2 года назад

      @@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?"

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

    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

    • @LlamAcademy
      @LlamAcademy  Год назад +1

      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

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

      @@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

  • @VerityD2
    @VerityD2 2 месяца назад

    door starts open and slidfes depending on where i am looking

  • @jerryfrommarketingdep
    @jerryfrommarketingdep 11 месяцев назад

    Is anyone having issue with the text colliding with the door and make it hard to read?

    • @LlamAcademy
      @LlamAcademy  11 месяцев назад

      To be sure the text is always on top you can use the "Overlay" shader from TextMeshPro.

  • @Ghareebz
    @Ghareebz 11 месяцев назад

    There's a Problem if you Duplicated the Door The Doors don't Open

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

    the use text goes into the walls help

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

      If you use the shader from TextMeshPro with “Overlay” in the name it won’t happen anymore

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

    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

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

      Check what you have versus what is on GitHub! There could be a small error causing it to not work! github.com/llamacademy/doors

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

      @@LlamAcademy my scripts are from the github and I am still having this issue

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

      @@SwampyWitch Did you get it resolved by using the new input system?

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

      @@LlamAcademy yeah

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

    i cant put my text to the use text

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

      Make sure your text is TextMeshPro, not UnityEngine.UI.Text or TextMeshProUGUI (the one that goes on a canvas)!

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

      @@LlamAcademy it is a text mesh pro

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

      @prodbyplayboii Here is the solution sorry for my english
      ruclips.net/video/jCaMG8rkAT8/видео.html

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

    THANK YOU

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

    how to use this in real 3d model door

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

      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

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

    How i open and close door for android🤧

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

      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!

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

      @@LlamAcademy okey thank😍 i try this

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

    Door Rotates and Slides normally but gets stuck in walls and can't close

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

      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

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

      @@LlamAcademy It wasn't this, but I rewrote the Closing functions and it worked. Thank you for responding tho ^^

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

    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.

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

      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 👌!

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

    wow this guy types fast

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

    Good

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

    Door namespace error

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

      The door is not in a namespace in this video. Without any information I can't help you.

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

      @@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
      @LlamAcademy  2 года назад +1

      @@eternaldebot4000 Let me check it out fresh off GitHub and see if I can reproduce that issue

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

      @@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

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

    This doesn't even work properly and there are errors in the code.

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

      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?

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

      @@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.

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

      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

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

      @@LlamAcademy great I'll try these fixes asap

  • @mohamedmusthafa1057
    @mohamedmusthafa1057 Год назад +1

    I love u brrrrrrrrro

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

    DOORS!!

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

    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! : ]

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

      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?

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

      @@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.

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

      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.