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

  Рет қаралды 35,059

SpeedTutor

SpeedTutor

3 жыл бұрын

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/SpeedTutorPatreon
·························································································
🔥 INSANE UNITY SAVINGS: bit.ly/UnitySalesHub
🕹️Synty Publisher Mega Sale: bit.ly/SyntyPublisherMegaSale
🕹️SpeedTutor Unity Store: bit.ly/STUnityStorePuzzlePacks
🕹️Unity New Release Discount Sale: prf.hn/l/BdvEmg3
🕹️Unity WELCOME2022 Offer: bit.ly/UnityWelcome2022OFFER
🔥 INSANE HUMBLE SAVINGS: bit.ly/HumbleBundleDeals
🕹️Humble Tutorial Bundle: bit.ly/MammothUnityTutorialsB...
🕹️Unity ART Bundle: bit.ly/UnityHumbleArtBundle
🕹️Unity TOOLS Bundle: bit.ly/UnityInsaneToolsBundle
🕹️SFX for Games Bundle: bit.ly/SFX-Music-For-Games
🕹️Learn Programming Games Bundle: bit.ly/LearnProgrammingGames
🔥Unity Materials / Files & More:
🕹️CGAxis 400 PBR Material Bundle: bit.ly/CGAxisPBRDeals
🕹️Synty Assets: bit.ly/SyntyLowPolyAssets
🕹️Filebase Assets: filebase.gamedevhq.com/ (Code: SPEEDTUTOR2022 - Sign up for a FREE MONTH)
🔥 UNITY SUBSCRIPTIONS:
🕹️Unity Plus: bit.ly/UnityPlusDeals
🕹️Unity Pro: bit.ly/UnityProDeals
·························································································
💰BIG DISCOUNTS on my website, for my UNITY ASSETS:
➡️www.speed-tutor.com
💬Join the Community Discord:
➡️ / discord
💝 Make a donation to the channel:
➡️www.paypal.me/speedtutor
·························································································
⬇️ SpeedTutor Puzzle Assets:
➡️Unity Store: bit.ly/STUnityStorePuzzlePacks
➡️My Website Discounts: www.speed-tutor.com/
⬇️ SpeedTutor Best Selling Assets:
🧩Adventure Puzzle Kit: bit.ly/STAdventurePuzzleKit
🗒️ Note & Letter System: bit.ly/STNoteLetterSystem
🔍Examine System: bit.ly/STExamineSystem
🔢Keypad System: bit.ly/STKeypadSystem
⬇️SpeedTutor Model Packs:
➡️Unity Store: bit.ly/STUnityStoreModelPacks
➡️My Website Discounts: www.speed-tutor.com/
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.com
·······················································································#SpeedTutor #Unity #DoorKey

Пікірлер: 204
@SpeedTutor
@SpeedTutor 3 жыл бұрын
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
@gmangman123
@gmangman123 3 жыл бұрын
thx so much my friend!!! Congratulations for 100 K subscriber!!!
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Thanks very much! :D
@adelbenhamida6188
@adelbenhamida6188 2 жыл бұрын
TYSMMMM i had some problem with the animations but now its working perfectly!!!
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Fantastic! I'm really glad to hear it, thanks for coming along to watch! :D
@dunderguy
@dunderguy 2 жыл бұрын
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
@barrelbrothers6896
@barrelbrothers6896 2 жыл бұрын
Thank you so much! Amazing tutorial
@SpeedTutor
@SpeedTutor 2 жыл бұрын
I'm glad you think so! Thanks for watching. :D
@SpeedTutor
@SpeedTutor 3 жыл бұрын
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.
@hermit5788
@hermit5788 3 жыл бұрын
Been waiting for this for so long i was forced to steal the code instead of making it
@SpeedTutor
@SpeedTutor 3 жыл бұрын
It's finally here! :)
@Shubham-bk2cf
@Shubham-bk2cf 3 жыл бұрын
you took so much time since u released the asset but finally its out :)
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I know! Haha, I'm sorry. I did the other 4 I think but this one got lost!
@qwerTeamxyz
@qwerTeamxyz Жыл бұрын
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! :)
@deadbroadcastpc
@deadbroadcastpc 3 жыл бұрын
Always so well explained man, appreciate it!
@SpeedTutor
@SpeedTutor 3 жыл бұрын
No worries at all, I'm glad you think so! :)
@dcry1003
@dcry1003 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
Yes I do, search my channel for optimization! :) You'll find the big video.
@macaaris1018
@macaaris1018 3 жыл бұрын
Nice video
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Thanks very much! :)
@WestyDesign
@WestyDesign 3 жыл бұрын
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 жыл бұрын
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.
@turotuwan7542
@turotuwan7542 3 жыл бұрын
Hi, can you show how exactly to setup door animation that you wrote in scripts with bool etc...?
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I have a tutorial, it's in the description too: kzfaq.info/get/bejne/ndBpeNRkvLCweqM.html& I hope that helps! :)
@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.
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Any errors?
@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?
@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?
@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.
@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?
@barkanuzmen
@barkanuzmen 2 жыл бұрын
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?
@faiz7180
@faiz7180 3 жыл бұрын
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 Ай бұрын
how do i lock the door after? is there a way opposite this
@Taqioca
@Taqioca 2 жыл бұрын
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 жыл бұрын
@@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 жыл бұрын
@@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!
@hurricaneblackandwhite1219
@hurricaneblackandwhite1219 3 ай бұрын
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?
@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! :)
@Smartoyunda
@Smartoyunda 3 жыл бұрын
i like your videos but ı wonder that is there a easier way to make door system
@SpeedTutor
@SpeedTutor 3 жыл бұрын
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 жыл бұрын
this guys makes the cleanest systems I have found.
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Thanks Rob!
@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;
@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 Жыл бұрын
same problem did you find the solution?
@thememesterr
@thememesterr Жыл бұрын
Could i do this but in VR or dose that requier alot more coding?
@SpeedTutor
@SpeedTutor Жыл бұрын
It's perfectly possible in VR! :)
@sharkfinn1840
@sharkfinn1840 2 жыл бұрын
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 2 жыл бұрын
So the animation doesn't play? They aren't static are they?
@sharkfinn1840
@sharkfinn1840 2 жыл бұрын
@@SpeedTutor I got it figured out :D Thanks for the tutorial.
@SpeedTutor
@SpeedTutor 2 жыл бұрын
How did you fix it?
@meltSTUDIO
@meltSTUDIO Жыл бұрын
@@sharkfinn1840 HOW TELL ME PLS
@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!
@pickle2835
@pickle2835 Жыл бұрын
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
@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.
@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. :)
@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 жыл бұрын
@@SpeedTutor but it's not working one key open all doors
@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?
@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 :)
@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 ай бұрын
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 😭
@nickbakk4947
@nickbakk4947 2 жыл бұрын
What should the animator controller be?
@SpeedTutor
@SpeedTutor 2 жыл бұрын
I'm not sure what you're asking me? :o
@galaziplays9975
@galaziplays9975 4 ай бұрын
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)
@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?
@danielmanogilmunuera6590
@danielmanogilmunuera6590 2 жыл бұрын
have you solve it?
@tuananhtran2944
@tuananhtran2944 2 жыл бұрын
Same problem here :(
@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 Жыл бұрын
@@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
@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! :)
@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?
@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 5 ай бұрын
Is the script name the same as the class name?
@matixss4783
@matixss4783 5 ай бұрын
@@SpeedTutor I feel a bit embarrassed to ask, but where can I find the class name?
@SpeedTutor
@SpeedTutor 5 ай бұрын
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 5 ай бұрын
@@SpeedTutor it is the same and still says no monobehavior scripts in the file, or thier names do not match the file name
@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
@spectechulars
@spectechulars Жыл бұрын
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 Жыл бұрын
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?
@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 жыл бұрын
@@SpeedTutor okay
@shoguneiraidenbaal359
@shoguneiraidenbaal359 3 жыл бұрын
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
@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?)
@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
@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! :)
@lamadox9140
@lamadox9140 5 ай бұрын
I can't select type from "keyItemcontroller". I can not see the options. what can I do?
@SpeedTutor
@SpeedTutor 5 ай бұрын
Is there any errors?
@lamadox9140
@lamadox9140 5 ай бұрын
@@SpeedTutor it is not say error.
@Ujjawalch642
@Ujjawalch642 3 жыл бұрын
Do it work same as in 2d game
@SpeedTutor
@SpeedTutor 3 жыл бұрын
It could if you changed it slightly.
@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 Жыл бұрын
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
@starduststudiosgaming971
@starduststudiosgaming971 2 жыл бұрын
fixed it
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Great to hear it, how did you fix it?
@starduststudiosgaming971
@starduststudiosgaming971 2 жыл бұрын
​@@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​
@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! :)
@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 :(
@WildGringo
@WildGringo 2 жыл бұрын
why the project is paid?
@SpeedTutor
@SpeedTutor 2 жыл бұрын
It's completely free to watch on KZfaq as you can see from the tutorial, I just have a small charge for all of my projects on Patreon :) To help with the costs of KZfaq.
@WildGringo
@WildGringo 2 жыл бұрын
@@SpeedTutor oh ok
@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
@mysteriuscat1696
@mysteriuscat1696 2 жыл бұрын
Works great... but one key opens all doors.
@SpeedTutor
@SpeedTutor 2 жыл бұрын
It doesn't do that for me, are you sure you're using different instances?
@mysteriuscat1696
@mysteriuscat1696 2 жыл бұрын
​@@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 жыл бұрын
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 жыл бұрын
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.
@kbdesigns1297
@kbdesigns1297 3 жыл бұрын
Anyone have trouble getting the door to close?
@SpeedTutor
@SpeedTutor 3 жыл бұрын
In what way? :o
@kbdesigns1297
@kbdesigns1297 3 жыл бұрын
@@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! :)
@ponffffes
@ponffffes 7 ай бұрын
animation doesn't work :(
@SpeedTutor
@SpeedTutor 7 ай бұрын
Your door isn't static, is it?
@ponffffes
@ponffffes 7 ай бұрын
@@SpeedTutor no
@Galaxy_World
@Galaxy_World 2 жыл бұрын
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 2 жыл бұрын
Not for beginners
@SpeedTutor
@SpeedTutor 2 жыл бұрын
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 жыл бұрын
I imagine you have a grammar or syntax issue somewhere close to that line. Maybe above or below. :)
@asian-man
@asian-man 2 жыл бұрын
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! :)
Door SOUNDS in Unity | Beginner Tutorial
5:05
SpeedTutor
Рет қаралды 13 М.
OPENING a DOOR in UNITY on TRIGGER EVENT
8:20
SpeedTutor
Рет қаралды 110 М.
A teacher captured the cutest moment at the nursery #shorts
00:33
Fabiosa Stories
Рет қаралды 52 МЛН
A little girl was shy at her first ballet lesson #shorts
00:35
Fabiosa Animated
Рет қаралды 15 МЛН
Задержи дыхание дольше всех!
00:42
Аришнев
Рет қаралды 3,7 МЛН
I can finally play as myself in UE5! (Metahuman Rig)
2:49
Nicole Celic
Рет қаралды 172
Make VR DOORS IN UNITY with NO CODE!
8:09
Daniel Stringer
Рет қаралды 11 М.
OPENING a DOOR using a BUTTON
18:38
SpeedTutor
Рет қаралды 24 М.
FIRST PERSON INTERACTION in Unity!
9:40
Kabungus
Рет қаралды 9 М.
unity for beginners - part 1
0:51
IndividualKex
Рет қаралды 461 М.
Creating Rope Objects with Physics | Unity Tutorial
10:36
Sasquatch B Studios
Рет қаралды 20 М.
How To Make UIs without frustration | Unity Beginner Tutorial
16:58
This is GameDev
Рет қаралды 30 М.
6 Ways To SAVE Your UNITY PROJECT from ruin!
12:14
SpeedTutor
Рет қаралды 1,5 М.
A teacher captured the cutest moment at the nursery #shorts
00:33
Fabiosa Stories
Рет қаралды 52 МЛН