OPENING a DOOR with a KEY! (Unity Beginner Tutorial)

Поділитися
Вставка
  • Опубліковано 21 сер 2024
  • In this Unity C# tutorial I show you how to code picking up a key, interacting with a door and opening and closing with animations - Using a basic raycast and controller scripts, creating a basic inventory and adding more functionality and timers to stop spamming of door interactions!
    ➡️Playing and Creating Animations: • Creating SIMPLE Animat...
    ➡️Creating a Crosshair UI: • Creating a Crosshair i...
    ➡️Door Interaction Kit: • Door Interaction Kit -...
    🎁 Get OVER 160+ Scripts, Projects and premium content on my PATREON HERE:
    ➡️bit.ly/SpeedTut...
    ·························································································
    🔥 INSANE UNITY SAVINGS: bit.ly/UnitySa...
    🕹️Synty Publisher Mega Sale: bit.ly/SyntyPu...
    🕹️SpeedTutor Unity Store: bit.ly/STUnity...
    🕹️Unity New Release Discount Sale: prf.hn/l/BdvEmg3
    🕹️Unity WELCOME2022 Offer: bit.ly/UnityWe...
    🔥 INSANE HUMBLE SAVINGS: bit.ly/HumbleB...
    🕹️Humble Tutorial Bundle: bit.ly/Mammoth...
    🕹️Unity ART Bundle: bit.ly/UnityHu...
    🕹️Unity TOOLS Bundle: bit.ly/UnityIn...
    🕹️SFX for Games Bundle: bit.ly/SFX-Mus...
    🕹️Learn Programming Games Bundle: bit.ly/LearnPr...
    🔥Unity Materials / Files & More:
    🕹️CGAxis 400 PBR Material Bundle: bit.ly/CGAxisP...
    🕹️Synty Assets: bit.ly/SyntyLo...
    🕹️Filebase Assets: filebase.gamed... (Code: SPEEDTUTOR2022 - Sign up for a FREE MONTH)
    🔥 UNITY SUBSCRIPTIONS:
    🕹️Unity Plus: bit.ly/UnityPl...
    🕹️Unity Pro: bit.ly/UnityPr...
    ·························································································
    💰BIG DISCOUNTS on my website, for my UNITY ASSETS:
    ➡️www.speed-tuto...
    💬Join the Community Discord:
    ➡️ / discord
    💝 Make a donation to the channel:
    ➡️www.paypal.me/s...
    ·························································································
    ⬇️ SpeedTutor Puzzle Assets:
    ➡️Unity Store: bit.ly/STUnity...
    ➡️My Website Discounts: www.speed-tuto...
    ⬇️ SpeedTutor Best Selling Assets:
    🧩Adventure Puzzle Kit: bit.ly/STAdven...
    🗒️ Note & Letter System: bit.ly/STNoteL...
    🔍Examine System: bit.ly/STExami...
    🔢Keypad System: bit.ly/STKeypa...
    ⬇️SpeedTutor Model Packs:
    ➡️Unity Store: bit.ly/STUnity...
    ➡️My Website Discounts: www.speed-tuto...
    My Assets include: Gas Mask, Flashlight, Generator, Themed Key , Padlock, Phone, Chess Puzzle, Lever, Valve Puzzle, Fuse Box & Safe Systems. Cardboard, Debris, Massive Models and more!
    ························································································
    ⭐ Connect with me:
    💬| Discord: / discord
    🐦| Twitter: / speedtutor
    📱 | Facebook: / speedtutoruk
    🖥 | Website: www.speed-tutor...
    ·······················································································#SpeedTutor #Unity #DoorKey

КОМЕНТАРІ • 201

  • @SpeedTutor
    @SpeedTutor  3 роки тому +5

    Lets find the keys to unlock your potential! Lets learn together today. :)
    🔥UNITY SAVINGS: bit.ly/UnitySalesHub
    🔥SpeedTutor Unity Store: bit.ly/STUnityStorePuzzlePacks
    🔥HUMBLE SAVINGS: bit.ly/HumbleBundleDeals

  • @SpeedTutor
    @SpeedTutor  3 роки тому +8

    I hope you guys find the tutorial useful! :) Do let me know if you have any new suggestions!

    • @gmangman123
      @gmangman123 3 роки тому

      very useful! Thx a lot of.

  • @dunderguy
    @dunderguy 2 роки тому +3

    Thank you so much you don't understand how long this has taken me to figure out

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      I'm glad you've found this helpful! :D

  • @adelbenhamida6188
    @adelbenhamida6188 2 роки тому +2

    TYSMMMM i had some problem with the animations but now its working perfectly!!!

    • @SpeedTutor
      @SpeedTutor  2 роки тому +1

      Fantastic! I'm really glad to hear it, thanks for coming along to watch! :D

  • @qwerTeamxyz
    @qwerTeamxyz Рік тому +2

    I just bought your themed key door Unlock System Asset which is obviously better and less time waste😂 Thanks mate for your wonderful tutorials and great videos!

    • @SpeedTutor
      @SpeedTutor  Рік тому

      Haha, thanks so much my friend. I really appreciate that! :)

  • @hermit5788
    @hermit5788 3 роки тому +4

    Been waiting for this for so long i was forced to steal the code instead of making it

  • @gmangman123
    @gmangman123 3 роки тому +1

    thx so much my friend!!! Congratulations for 100 K
    subscriber!!!

  • @Shubham-bk2cf
    @Shubham-bk2cf 3 роки тому +3

    you took so much time since u released the asset but finally its out :)

    • @SpeedTutor
      @SpeedTutor  3 роки тому +2

      I know! Haha, I'm sorry. I did the other 4 I think but this one got lost!

  • @deadbroadcastpc
    @deadbroadcastpc 3 роки тому +6

    Always so well explained man, appreciate it!

    • @SpeedTutor
      @SpeedTutor  3 роки тому +2

      No worries at all, I'm glad you think so! :)

  • @barrelbrothers6896
    @barrelbrothers6896 2 роки тому +1

    Thank you so much! Amazing tutorial

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      I'm glad you think so! Thanks for watching. :D

  • @macaaris1018
    @macaaris1018 3 роки тому +2

    Nice video

  • @dcry1003
    @dcry1003 Рік тому +1

    so ive already finish your other video on raycast door *which is so helpful and amazing thank you!* and i just wanna ask can i use both the other raycast door in tandem with this one? like putting the raycast script and keyraycast script in the camera

    • @SpeedTutor
      @SpeedTutor  Рік тому +1

      You could do that but it wouldn't be particularly optimised, you could just create a script which is found in either case and check which type of door it is :)

    • @dcry1003
      @dcry1003 Рік тому

      @@SpeedTutor thanks you! btw do you have a video about game optimization or how to fully optimize your game?

    • @SpeedTutor
      @SpeedTutor  Рік тому +1

      Yes I do, search my channel for optimization! :) You'll find the big video.

  • @pickle2835
    @pickle2835 Рік тому +1

    I don't understand how to play the animation when the door is clicked with the key

    • @SpeedTutor
      @SpeedTutor  Рік тому

      Do I show that in this video?

    • @pickle2835
      @pickle2835 Рік тому

      @@SpeedTutor yeah, I watched both videos and i still dont understand how to link the animation to the door

    • @pickle2835
      @pickle2835 Рік тому

      @@SpeedTutor Never mind turns out i was missing a chunk of code from the KeyDoorController script thanks for the tutorial it all works now

  • @Smartoyunda
    @Smartoyunda 3 роки тому +2

    i like your videos but ı wonder that is there a easier way to make door system

    • @SpeedTutor
      @SpeedTutor  3 роки тому +1

      Of course, the possibilities are endless - This is just one example of how you could go about doing it! Thanks for checking it out though. :)

    • @bertconnell
      @bertconnell 3 роки тому +2

      this guys makes the cleanest systems I have found.

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      Thanks Rob!

  • @Bulderme
    @Bulderme 2 роки тому

    I believe I am having some issues with the door not opening and the UI not showing up. The key collects just fine and the cursor works great on the key and door.

  • @barkanuzmen
    @barkanuzmen 2 роки тому +1

    Great tutorial! However, I have a problem. When I try to open or close the door after picking up the key, the animations play infinitely. For example, when i try to open the door DoorOpen animation plays endlessly. I checked the code and I am sure that the code only work once when I do that.

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      Did you turn off loop in the animation?

  • @WestyDesign
    @WestyDesign 3 роки тому +2

    Fantastic tutorial! Everything I wanted & needed!
    I had a question about the crosshair though - how would I go about making it an image like a small dot by default, then making that dot turn into a different image (like a keycard) when i'm looking at a door?
    I think it'd look great with the code you set up with this tutorial (and it'd be perfect for the game i'm making!)
    And thanks again for making this tutorial, it's fantastic :D

    • @SpeedTutor
      @SpeedTutor  3 роки тому +2

      Thanks very much for saying so, in the method towards the bottom of the raycast where we change the colour of the crosshair, instead of changing the colour - Make this an image UI swap. You could use ".SetActive(true/false);" on a different UI in same place as the dot! :) I hope that helps.

  • @Taqioca
    @Taqioca 2 роки тому +1

    Hi SpeedTutor, your tutorial is amazing so far. I got the crosshair, pick up key, door lock worked. Everything seems fine except opening the door animation. When I picked up the key and clicked the door. the game crashed saying
    NullReferenceException: Object reference not set to an instance of an object
    KeySystem.Key.KeyDoorController.PlayAnimation()

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      Do you have the correct animation component on your door?

    • @Taqioca
      @Taqioca 2 роки тому +1

      @@SpeedTutor Nvm, fixed it. turns out it was public void Awake. I wrote "awake" instead of Awake. I can't believe that one letter was the cause of the crash. crazyyy. I wish Unity could have point out where the problem was instead of having me spending many hours looking for it. Anyways, thanks for the awesome tutorial!

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      I know the feeling! This is why you always have to go through error messages step by step. Look at what it's pointing to, and even what line might be pointing to another. It's a game of cat and mouse, most of the time! Good work though :)

    • @Taqioca
      @Taqioca 2 роки тому +1

      @@SpeedTutor Unity was pointing the error at the key door script at line 53 which is the PlayAnimation part. So I thought it has something to do with the animator component like I was missing something xD. But yeah, I should have double-checked the script. Anyways, it's a good learning lesson haha. Thanks again!

  • @faiz7180
    @faiz7180 3 роки тому +1

    I followed two of your door tutorial. The one with and without key. Both worked perfectly but the crosshair color for door with key is not changing and crosshair for door without key works fine. It's not really going to drag the game down because the scripts is all good but I would like to know the reason behind this. Any possible reason? I use the same crosshair for both door btw.

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      I'm not sure, maybe you're missing a tag?

    • @kmanb
      @kmanb Рік тому

      I know this is late, but in case other people have the same issue:
      I fixed this problem by making a separate tag for the interactableTag for the door that uses the key.
      For example, instead of: private string interactableTag = "InteractiveObject";
      For the key door I used: private string interactableTag = "InteractiveKeyObj";
      Hope this helps!

  • @muhdfathris
    @muhdfathris 2 місяці тому

    how do i lock the door after? is there a way opposite this

  • @shoguneiraidenbaal359
    @shoguneiraidenbaal359 3 роки тому +1

    NullReferenceException: Object reference not set to an instance of an object
    KeySystem.keyDoorController.PlayAnimation () (at Assets/Scripts/Dont work/keyDoorController.cs:38)
    KeySystem.keyItemController.ObjectInteraction () (at Assets/Scripts/Dont work/keyItemController.cs:28)
    KeySystem.keyRayCast.Update () (at Assets/Scripts/Dont work/keyRayCast.cs:44)

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      I'm not sure what lines these are?

    • @kmanb
      @kmanb Рік тому

      @@SpeedTutor lines 38, 28, and 44 according to the error

  • @turotuwan7542
    @turotuwan7542 3 роки тому

    Hi, can you show how exactly to setup door animation that you wrote in scripts with bool etc...?

    • @SpeedTutor
      @SpeedTutor  3 роки тому +1

      I have a tutorial, it's in the description too: ua-cam.com/video/gj9Eq3WJLJo/v-deo.html&
      I hope that helps! :)

  • @AlexKuNTH
    @AlexKuNTH 2 роки тому

    Thanks for the tutorial! but there's a problem to me when I try to add more key.
    I don't know I missed something or not. But when I added another key, I can pick up that key.
    but when I tried to open the door, I got a NullReferenceException in KeyItemController.ObjectInteraction.
    I check the error line and it's a "doorObject.PlayAnimation".
    I don't know what to do. I change the type of door and key and already have the animation.

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      Does your door object have an animation component?

    • @AlexKuNTH
      @AlexKuNTH 2 роки тому

      @@SpeedTutor Yes, I've already put it. I tried to create a new one and copy the old one but they still have same problem when I change to other door that isn't a first door. ;w;

  • @galaziplays9975
    @galaziplays9975 5 місяців тому +1

    I dont know what I'm doing wrong.
    Whenever I click the door w/ or w/o the key, I get this same error.
    NullReferenceException: Object reference not set to an instance of an object
    KeySystem.KeyItemController.ObjectInteraction () (at Assets/My Assets/My Scripts/KeyItemController.cs:28)
    KeySystem.KeyRaycast.Update () (at Assets/My Assets/My Scripts/KeyRaycast.cs:43)

  • @MalKlein
    @MalKlein 7 місяців тому

    Hi I am continuously trying this tutorial for 3 days now😂 I was trying to replace the mouse click with just pressing ’D’. I am pretty sure I have followed everything correctly! I don’t know why it’s not working. Like literally anything, can’t pick up the key, no UI, can’t open the door..is there any way I could share the scripts with you so you can take a look? I would really appreciate that. Thanks!

    • @SpeedTutor
      @SpeedTutor  7 місяців тому

      You can join my Discord and post the script in there, are you sure you're using the correct tags? Always best to add Debug.Log lines into your code to see if each part is working. :)

  • @hurricaneblackandwhite1219
    @hurricaneblackandwhite1219 4 місяці тому

    the 2 namespaces tool and image weren't found is the image one because i already have a script with one of your other ray casted doors? and idk what to do about the tool part?

    • @SpeedTutor
      @SpeedTutor  3 місяці тому

      I'm not sure what you mean?

  • @random_precision_software
    @random_precision_software 3 роки тому

    You lost me at first on the bit wise but it's like Assembly language were you rotate left out shift left or right?

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      Pretty much, it's just comparing the two layers. I don't really know why but that's the way to do it! Haha.

  • @bmpproductions
    @bmpproductions 2 роки тому

    I don't normally ask about things through comments and I know this comment is late on this video as well, but I am genuinely confused about what I'm doing wrong. I've created more keys and doors, have set up the script onto each thing, but when I collect one key, it allows me to open all doors. Not simultaneously, but individually without having to collect the actual key for that specific door.

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      Did you set a boolean on each particular door and have it check if you have a particular key? :o

    • @bmpproductions
      @bmpproductions 2 роки тому

      @@SpeedTutor I believe so, I may have done something wrong with it, but I'm not really sure. I just know that the doors work and the keys can be collected, but for some reason, it doesn't matter which key is collected as it opens all the doors without having that doors specific key. I feel like I've messed up somewhere with the keys or something. By chance it is the booleans, which script would I be checking for the booleans for each door?

    • @MatrixCreator-01
      @MatrixCreator-01 Рік тому

      @@bmpproductions did you find the solutions?

    • @bmpproductions
      @bmpproductions Рік тому +1

      @@MatrixCreator-01 Unfortunately, not in the way I had hoped. The only thing that worked for me was doing it in an annoying and more difficult way by making a separate script for every door. Although, I don't really recommend doing that because it really isn't very efficient.

    • @MatrixCreator-01
      @MatrixCreator-01 Рік тому

      @@bmpproductions somehow I found a easy or you can say shortcut

  • @user-we5yg5yy2d
    @user-we5yg5yy2d 2 роки тому

    Your tutorial is very good. But now I have some questions, cuz I can't interact with the key(crosshair wont change color and key cannot be picked),but the door is normal(when crosshair is on it, it turned red and can show doorlocked UI),any possible reason?

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      Do this system use tags and layers? I can't recall? If so, you might want to make sure nothing is occluding the key? Big enough box collider? Did it work before?

  • @mentalwolfgames8454
    @mentalwolfgames8454 2 роки тому

    Hey thank you for the tutorial I had a question I am using Dungeon Builder(UnityAsset) to Create random worlds I made the door a prefab however the keyInventory EmptyObject gets removed for each door is there a way to add into the script to look for the keyInventory after each door is created?

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      Would finding the Gameobject and compoennt on start work?

  • @lamadox9140
    @lamadox9140 6 місяців тому

    I can't select type from "keyItemcontroller". I can not see the options. what can I do?

    • @SpeedTutor
      @SpeedTutor  6 місяців тому

      Is there any errors?

    • @lamadox9140
      @lamadox9140 6 місяців тому

      @@SpeedTutor it is not say error.

  • @Vladislav-Listev
    @Vladislav-Listev 3 роки тому

    If you have 20 different keys, you suggest for each write if else statement? This code doesnt look OOP

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      This is just one example of how you could do it! :)

    • @h.korayonel7148
      @h.korayonel7148 2 роки тому +1

      @@SpeedTutor but it's not working one key open all doors

  • @galberger3937
    @galberger3937 9 місяців тому

    How to use the pickUp key code to pickUp a flashlight and to make that flashlight work with a FPS controller?

    • @SpeedTutor
      @SpeedTutor  9 місяців тому

      I have a Unity asset on my store page just for that :)

  • @elenavillepreux1842
    @elenavillepreux1842 2 роки тому

    Hi ! very nice and useful tutorial. However I use Mirror for network multiplayer and it doesn't seem to work for me, what can I do? Do i have to replace Monobehavior by NetworkBehavior ?

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      Sorry, that's not something I'm sure about at all.

  • @matixss4783
    @matixss4783 6 місяців тому

    Can't add script component "keyitemcontroller" because the script class cannot be found i have the same problem with door and raycast. And its says that there is no monobehavior scripts in the files

    • @SpeedTutor
      @SpeedTutor  6 місяців тому

      Is the script name the same as the class name?

    • @matixss4783
      @matixss4783 6 місяців тому

      @@SpeedTutor I feel a bit embarrassed to ask, but where can I find the class name?

    • @SpeedTutor
      @SpeedTutor  6 місяців тому

      That's alright, don't worry. If you open up one of your script at the very top it will have something like: public class "NAMEOFCLASS" : MonoBehaviour - Just change the name of the class there :)

    • @matixss4783
      @matixss4783 6 місяців тому

      @@SpeedTutor it is the same and still says no monobehavior scripts in the file, or thier names do not match the file name

  • @xrono6003
    @xrono6003 2 роки тому

    Thanks a lot for this tutorial, one question : How can I add a lock sound when the player touches the door when he doest have the key? I tried figure it out myself but I have no idea where to place the audioplay

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      You could do it when we check for the interaction, if you don't have a specific key play the audio. You might need to make a check if one doesn't already exist! :)

    • @xrono6003
      @xrono6003 2 роки тому

      @@SpeedTutor Whats the name of the asset pack?

  • @GbrlFerz
    @GbrlFerz 3 роки тому

    I'm doing something wrong trying to add more keys and doors. When I try it, if I have any key at all, I'm able to open any door.
    Am I missing something?

  • @hampusgranberg6382
    @hampusgranberg6382 Рік тому

    Nice tutorial, but I ran into a problem.
    If I first interact with the key, the game object disappears as it should, but I can't interact with the door.
    But if I first interact with the door, it says "Door locked", and if I then interact with the key, it also says "Door locked".
    I've assigned the red key to "red key", and the door to "red door", but for some reason, they're treated the same.

    • @SpeedTutor
      @SpeedTutor  Рік тому

      Are you sure the script is looking for the correct tags in this case?

    • @hampusgranberg6382
      @hampusgranberg6382 Рік тому

      @@SpeedTutor Yup, the Layer Mask Interact on the Camera's Key Raycast Script is on "Interact".
      The door objects tag is "InteractiveObject", and layer on "Interact", and the red key object is tagged "InteractiveObject" as well as on the "Interact" layer.

    • @hampusgranberg6382
      @hampusgranberg6382 Рік тому

      I got it working. I had ignored all the code on the crosshair section, because I didn't want a crosshair ingame, and it caused the issue. Works now, but my method is basically having an invisible crosshair there, in order for it to function. Would this be advisable, or is there another better way to do it?

  • @charathelamp7953
    @charathelamp7953 3 роки тому

    Is the KeyRaycast script the exact same as the DoorRaycast you made a while back?

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      It's similar, if not the same with maybe a couple of lines changed! :)

  • @norbertbinkowski424
    @norbertbinkowski424 3 роки тому

    Hello. Did you remove Door Interaction Kit? Asset Store shows it as Deprecated.

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      It's now part of my Patreon because I'm trying to raise money for the channel! :) Thanks for taking an interest!

  • @rishibhatt8124
    @rishibhatt8124 9 місяців тому

    Hey, I have a problem where i cant drag my game object into the My Door part of the script. Im using a regular game object and not a model. Any fix?

    • @SpeedTutor
      @SpeedTutor  9 місяців тому +1

      Is it because it's missing the particular component it's looking for in the inspector slot? :)

    • @rishibhatt8124
      @rishibhatt8124 9 місяців тому

      @@SpeedTutor i got it, thanks for the reply and the tutorial! Super helpful for my college project 😭

  • @meltSTUDIO
    @meltSTUDIO Рік тому

    Can you pls help me? Im getting error with a StartCorountine(PauseDoorInteraction()); and StartCorountine(ShowDoorLocked());

    • @SpeedTutor
      @SpeedTutor  Рік тому

      What's the error?

    • @meltSTUDIO
      @meltSTUDIO Рік тому

      @@SpeedTutor KeyDoorController.cs(45, 36) CS1503 Argument1: cannot convert from 'System.Collections.IEnumerable' to 'string'

    • @meltSTUDIO
      @meltSTUDIO Рік тому

      I fixed it, i write numerable not numerator

    • @meltSTUDIO
      @meltSTUDIO Рік тому

      @@SpeedTutor I got other problem, the key pick-up, but the door wont open when i click on it. I tried to remake this two times and nothing.

    • @meltSTUDIO
      @meltSTUDIO Рік тому

      @@SpeedTutor nvm i fixed it. Ty for tutorial

  • @ays.fennix
    @ays.fennix Рік тому

    Hey umm, so I cant add the script onto the key, its telling me "Can't add script component 'KeyItemController' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match." what does this mean? and how can i fix it? I'm quite new to coding ^^"

    • @SpeedTutor
      @SpeedTutor  Рік тому

      Is your script the same name as your class name?

  • @clear4476
    @clear4476 2 роки тому

    So Im trying to use this system with a lot of keys and a lot of doors. So I added more else if statements with the names of the other keys but I cant open all doors with all keys still. Do you know a solution for this or know someone that does?

    • @spectechulars
      @spectechulars 2 роки тому +1

      same problem did you find the solution?

  • @mysteriuscat1696
    @mysteriuscat1696 2 роки тому +2

    Works great... but one key opens all doors.

    • @SpeedTutor
      @SpeedTutor  2 роки тому +1

      It doesn't do that for me, are you sure you're using different instances?

    • @mysteriuscat1696
      @mysteriuscat1696 2 роки тому +1

      ​@@SpeedTutor I made the different keys the way you said in the video and changed the key tag for the other key I made, but picking up any key causes all key doors to open. Is there anything that I have to do for the other door/doors to let only one key work for each door/doors?

    • @mysteriuscat1696
      @mysteriuscat1696 2 роки тому +1

      When it didn't work I added classes to each key and even added different door classes and tags. I tried different things and none of them worked, one key still opened all doors.

    • @mysteriuscat1696
      @mysteriuscat1696 2 роки тому

      @@SpeedTutor I'm pretty sure I'm using different instances.

    • @mysteriuscat1696
      @mysteriuscat1696 2 роки тому +2

      I Figured it out. Though I had to make a different door controller script for each door and add new doors as well for those who are curious.

  • @sharkfinn1840
    @sharkfinn1840 3 роки тому

    Great tutorial! i just had 1 problem. i have a sliding door with two panels and when i have the key and try to open it, nothing happens

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      So the animation doesn't play? They aren't static are they?

    • @sharkfinn1840
      @sharkfinn1840 3 роки тому +1

      @@SpeedTutor I got it figured out :D Thanks for the tutorial.

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      How did you fix it?

    • @meltSTUDIO
      @meltSTUDIO Рік тому

      @@sharkfinn1840 HOW TELL ME PLS

  • @Derbyskiller
    @Derbyskiller Рік тому

    Brother i have a Problem, the script error says that CrosshairChange, Crosshair, and doOnce is not there. I made this what you did. Can you help me pls i not know what is wrong.

    • @SpeedTutor
      @SpeedTutor  Рік тому

      I'm not sure without seeing your script?

    • @Derbyskiller
      @Derbyskiller Рік тому

      @@SpeedTutor This is the Script
      I dont know whats false:(
      :
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      using UnityEngine.UI;
      namespace KeySystem
      {
      public class KeyRaycast : MonoBehaviour
      {
      [SerializeField] private int raylength = 5;
      [SerializeField] private LayerMask layerMaskInteract;
      [SerializeField] private string excluseLayerName = null;
      private KeyItemController raycastedObject;
      [SerializeField] private KeyCode openDoorKey = KeyCode.Mouse0;
      [SerializeField] private Image crosshair = null;
      private bool isCrosshairActive;
      private bool doOnce;

      private string interactableTag = "InteractiveObject";
      private void Update()
      {
      RaycastHit hit;
      Vector3 fwd = transform.TransformDirection(Vector3.forward);
      int mask = 1

  • @thememesterr
    @thememesterr Рік тому

    Could i do this but in VR or dose that requier alot more coding?

    • @SpeedTutor
      @SpeedTutor  Рік тому

      It's perfectly possible in VR! :)

  • @starduststudiosgaming971
    @starduststudiosgaming971 2 роки тому +1

    fixed it

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      Great to hear it, how did you fix it?

    • @starduststudiosgaming971
      @starduststudiosgaming971 2 роки тому +1

      ​@@SpeedTutor I added bools to the door controller script for each door then made the open door function only trigger if you had the right key and the right bool was ticked​

  • @spectechulars
    @spectechulars 2 роки тому

    in my scenario i have multiple doors and each door has its specific key can you please help me to solve the problem

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      It should work for that :)

    • @doriantermini
      @doriantermini Рік тому

      @@SpeedTutor This is not a good way to help people, just saying "Yeah it should work" doesn't help.

    • @dcry1003
      @dcry1003 Рік тому

      @@doriantermini if the question isnt clear and almost written as if its saying "hey look i did this" and just ask for help *without stating what the problem is* then what else could he do?

  • @nickbakk4947
    @nickbakk4947 2 роки тому

    What should the animator controller be?

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      I'm not sure what you're asking me? :o

  • @Sora-li3ob
    @Sora-li3ob 3 роки тому

    Have you done one where it's a password instead of a key?? If not will you do one?

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      I have an asset on the Unity store which does this! :)

  • @alup4rk
    @alup4rk 2 роки тому

    i have a question my unity crashes when i pick up the red key and look at the door do you know what causes this?

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      Do you have errors? Is this crashing in the editor?

    • @alup4rk
      @alup4rk 2 роки тому

      @@SpeedTutor nope its crashing while i test it

    • @alup4rk
      @alup4rk 2 роки тому

      @@SpeedTutor can i get your email or something i can send a video tomorrow? :)

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      Sure you can get my email from the "About" page on my channel, through my website or even message me on Discord :)

    • @alup4rk
      @alup4rk 2 роки тому +1

      @@SpeedTutor okay

  • @LeetardPlays
    @LeetardPlays Рік тому

    Hola Gamers!
    Having a wee problemo here. The key object nor the door object are doing anything. Crosshair doesn't change colour and the text won't show on screen. There's no error messages or issues in the code from what I've seen. If anyone has any suggestions or solutions I'll give you a virtual high five! Version: Unity 2021.3.9f1

    • @SpeedTutor
      @SpeedTutor  Рік тому +1

      That's really hard to diagnose, I can't remember if this code relies on tags?

    • @LeetardPlays
      @LeetardPlays Рік тому

      @@SpeedTutor Thanks for responding! It does rely on tags 'InteractiveObject' for the tag and 'Interact' for the layer

  • @masgroup2000
    @masgroup2000 3 роки тому

    is this a update for the door asset ?

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      No, no - This is already included in the door asset but it's showing everyone how to make it, if they don't have the pack! :)

  • @scotttowers1759
    @scotttowers1759 2 роки тому

    I get (12,60): error CS1519: Invalid token '=' in class, struct, or interface member declaration
    This seems to be referring to the key item controller script. I'm new to this so can anyone help? Pleeeaseeeeeee

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      What is on line 12?

    • @scotttowers1759
      @scotttowers1759 2 роки тому

      @@SpeedTutor thanks for the reply.
      Full code:
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      namespace KeySystem
      {
      public class KeyItemController : MonoBehaviour
      {
      [SerializeField] private bool houseDoor = false;
      [SerializeField] private bool BlackKey = false;
      [SerializeField] private KeyInventory_keyInventory = null;
      private KeyDoorController doorObject;
      private void Start()
      {
      if (houseDoor)
      {
      doorObject = GetComponent();
      }
      }
      public void ObjectInteraction()
      {
      if (houseDoor)
      {
      doorObject.PlayAnimation();
      }
      else if (BlackKey)
      {
      _KeyInventory.hasBlackKey = true;
      gameObject.SetActive(false);
      }
      }
      }
      }
      Line 12:
      [SerializeField] private KeyInventory_keyInventory = null;

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      Is that because you don't have a space between "KeyInventory" and "_keyInventory"?
      Also "_keyInventory" - This is the variable
      Is spelt different to:
      _KeyInventory.hasBlackKey = true; - This is what you use in the code.

    • @scotttowers1759
      @scotttowers1759 2 роки тому

      @@SpeedTutor hi, I done that and I'm now getting three further errors with the raycast.
      (17,35) error CS0246: The type or namespace name 'Image' could not be found (are you missing a using directive or assembly reference?)
      (17,10) error CS0246: The type or namespace name [SerializedFieldAttribute] could not be found (are you missing a using directive or assembly reference?)
      (17,10) error CS0246: The type or namespace name [SerializedField] could not be found (are you missing a using directive or assembly reference?)

  • @JamJonks
    @JamJonks 2 роки тому

    No matter what I try I get the same error. "The script don't inherit a native class that can manage a script".

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      Is the class name the same as the script name?

    • @JamJonks
      @JamJonks 2 роки тому

      @@SpeedTutor They all have "public class Example : MonoBehaviour " with their names being the same as the script names

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      You want to give each of your classes a different name

    • @JamJonks
      @JamJonks 2 роки тому

      @@SpeedTutor
      KeyRaycast - "public class KeyRaycast : MonoBehaviour"
      KeyInventory - "public class KeyInventory : MonoBehaviour"
      KeyDoorController - "public class KeyDoorController : MonoBehaviour "
      KeyItemController - "public class KeyItemController : MonoBehaviour"
      I think these are the classes you're talking about?

    • @JamJonks
      @JamJonks 2 роки тому

      @@SpeedTutor I don't know how :(

  • @Ujjawalch642
    @Ujjawalch642 3 роки тому

    Do it work same as in 2d game

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      It could if you changed it slightly.

  • @ponffffes
    @ponffffes 8 місяців тому

    animation doesn't work :(

    • @SpeedTutor
      @SpeedTutor  8 місяців тому

      Your door isn't static, is it?

    • @ponffffes
      @ponffffes 8 місяців тому

      @@SpeedTutor no

  • @unreals9492
    @unreals9492 3 роки тому

    İs this works on mobile ?

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      It could work on mobile, I've never tested it but I don't see why not! :)

  • @dexterdextrow7248
    @dexterdextrow7248 Рік тому

    it works, but only for one key it seems. which is a bit disappointing. i don't understand why he didn't just show how to add additional keys and doors, if it indeed works.

    • @SpeedTutor
      @SpeedTutor  Рік тому

      It indeed does work for multiple keys and doors, you just need to add them yourself as additional variables. :)

    • @dexterdextrow7248
      @dexterdextrow7248 Рік тому

      @@SpeedTutor yea, i understood as much, although one key would open all doors for me. I'd just suggest showing how to implement at least one extra key, so that there's an example to go after.

    • @dexterdextrow7248
      @dexterdextrow7248 Рік тому

      @@SpeedTutor you know, just saying "hey, yea, this works" doesn't really help those who have problems expanding the system.

    • @ivankovacevic5757
      @ivankovacevic5757 11 місяців тому

      Hey I had the same problem how did you solve it?@@dexterdextrow7248

  • @kbdesigns1297
    @kbdesigns1297 3 роки тому

    Anyone have trouble getting the door to close?

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      In what way? :o

    • @kbdesigns1297
      @kbdesigns1297 3 роки тому +1

      @@SpeedTutor It was a syntax error in the script I didn't notice. I had tired eyes. All good now, great tutorial, very helpful!

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      Fantastic! Good work! :)

  • @Galaxy_World
    @Galaxy_World 2 роки тому +1

    Soooo zoomed out omg

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      Sorry about that, it's always pretty zoomed in on my screen but I'll make it bigger for next time :)

  • @ApexArtistX
    @ApexArtistX 3 роки тому

    quit at Keyinventory script... need a cube tutorial not a pre set up game

    • @SpeedTutor
      @SpeedTutor  3 роки тому

      I do have several other tutorials showing you how to add doors and other such things! :)

  • @ApexArtistX
    @ApexArtistX 3 роки тому +1

    Not for beginners

    • @SpeedTutor
      @SpeedTutor  3 роки тому +1

      I believe in you! You can do it!

  • @asian-man
    @asian-man 2 роки тому

    Unity returns error CS1002 on two lines with WaitForSeconds() at KeyDoorController.cs. It expects a semicolon even if it's typed already. I use Unity 2020.3.33f1.

    • @SpeedTutor
      @SpeedTutor  2 роки тому +1

      I imagine you have a grammar or syntax issue somewhere close to that line. Maybe above or below. :)

    • @asian-man
      @asian-man 2 роки тому +1

      I have checked the syntax few hours ago, and realized that I typed "now" instead of "new." Thank you! 😊 I think I need more rest.

    • @SpeedTutor
      @SpeedTutor  2 роки тому

      Haha, it easily be done. Good job on fixing it! :)