OPENING a DOOR in UNITY with a RAYCAST

  Рет қаралды 52,371

SpeedTutor

SpeedTutor

Күн бұрын

In this Unity C# tutorial I show you how to animate a door, interact with it to open and close with animation using a basic raycast and controller script. I show you how to set the pivot, create the animation, write the scripts and then implement a fully open/close door feature! I will have more versions of this soon and will be uploaded to the Unity asset store for FREE!
➡️Door Interaction Kit on the Unity Asset Store: bit.ly/STDoorInteractionKit
·························································································
🎁 Get OVER 210+ Scripts, Projects and premium content on my PATREON HERE:
➡️bit.ly/SpeedTutorPatreon
➡️Playing and Creating Animations: • Creating SIMPLE Animat...
➡️Creating a Crosshair UI: • Creating a Crosshair i...
➡️Creating Entire Door System with ChatGPT: • Create Interactive Doo...
Check out the FREE tutorials here:
➡️Basic Raycast Door: • INSPECT System Tutoria...
➡️Trigger Door: • INSPECT System Tutoria...
➡️Raycast Button Raycast Door - • OPENING a DOOR using a...
➡️Key Open Door Raycast - • OPENING a DOOR with a ...
➡️Hinge Door - • Creating a HINGE DOOR ...
➡️Adding Door Sounds: • Door SOUNDS in Unity |...
·························································································
➡️(My Game) Left Alone on Steam: speedtutor.net/LeftAlone2024
🔥SpeedTutor Unity Store: bit.ly/STUnityStorePuzzlePacks
🔥 INSANE UNITY SAVINGS: bit.ly/UnitySalesHub
🕹️Unity Sales: bit.ly/UnitySalesHub
🕹️Quick-Start Bundle: bit.ly/UnityQuickStartBundle
🕹️Weekly Publisher Sale (+FREE Asset): bit.ly/WeeklyPublisherSale
🕹️Unity New Release Discount Sale: prf.hn/l/BdvEmg3
🔥 INSANE HUMBLE SAVINGS: bit.ly/HumbleBundleDeals
🕹️30 for $30 Unity Tools Bundle: bit.ly/HumbleUnityTools30for3...
🕹️Massive 2D Megabundle: bit.ly/Massive2DMegabundle
🕹️Insane Unity & Unreal Environment Bundle: bit.ly/UltimateUnityUnrealEnv...
🕹️Unity RPG Tutorial: bit.ly/UnityRPGTutCollectionH...
🔥 FANATICAL GAMEDEV BUNDLES: bit.ly/FanaticalGameDevBundles
🕹️Fanatical Bundle Savings (+20% OFF): bit.ly/FanaticalProgrammersDa...
🕹️Low Poly Unity Bundle: bit.ly/FanaticalLowPolyBundle
🕹️RPG Game Builder Assets: bit.ly/FanaticalRPGGameAssets
🕹️Unity-Unreal-Godot eLearning Bundle: bit.ly/MassiveUnityCodingGame...
🔥Synty Discounts & Savings: bit.ly/SyntyLowPolyAssets
🔥Unity Pro Deals: bit.ly/UnityProDeals
🔥Topcashback: bit.ly/TopcashbackReferral
·························································································
💰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
·······················································································
#Unity #OpeningDoors #Doors

Пікірлер: 426
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Lets cast a spell on this door and open it up! Who's with me? :D 🔥UNITY SAVINGS: bit.ly/UnitySalesHub 🔥SpeedTutor Unity Store: bit.ly/STUnityStorePuzzlePacks 🔥HUMBLE SAVINGS: bit.ly/HumbleBundleDeals
@clericnorsegaming173
@clericnorsegaming173 3 жыл бұрын
Such a good tutorial..... Literally I have spent 10 hrs and watched a totally of 30 tutorials to get my dang door to open.... NONE OF THEM WORKED UNTIL I FOUND YOURS! My only problem is my animations are not showing up the door will open knocking my player out of the way but the doors in the exact same spot XD atleast now I can walk into my town :D So Ill have to figure out why my animations aren't working!
@II-or8pw
@II-or8pw 3 жыл бұрын
Thank you, learning unity right now and this helped a lot for a group project i have in school, really easy to follow and very clear to understand, thank you !
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I'm really glad you liked it! :)
@Old.Badger
@Old.Badger 3 жыл бұрын
Thank you very much, I don't know how I can repay you more than by liking and taking subscribe, I was looking for a tutorial on the door for several hours and you described it best and most functionally.
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You're most welcome! Good luck! :)
@lifeinthehands6972
@lifeinthehands6972 2 жыл бұрын
@@SpeedTutor Thank you for the video bro. But I want to make this at mobile devices. How can I set the mouse0 button. I have to do it with Touch input.
@dragonanimations0748
@dragonanimations0748 6 ай бұрын
THANK YOU SO MUCH FOR MAKING THIS TUTORIAL... IVE BEEN LOOKING FOR SOMETHING LIKE THIS FOR HOURS 😭😭
@SpeedTutor
@SpeedTutor 6 ай бұрын
You're very welcome! :D I have a full asset on the Unity store for this type of thing with full customisation.
@dragonanimations0748
@dragonanimations0748 6 ай бұрын
@@SpeedTutor would i be able use this tutorial multiple times in one setting? if so would I have to make a new script per object even if they have the same animation. For example, I'm currently working on making a target shooter game and have been struggling with making the collapse animation play when the target is shot by a raycast. I've been able to get this code for one target, though it gets a little finicky at times, I've been having trouble applying the code to multiple targets. Any suggestions?
@rajdhuri2946
@rajdhuri2946 2 жыл бұрын
Thank You so much for this Great Tutorial 🙌🏻
@SpeedTutor
@SpeedTutor 2 жыл бұрын
You're very welcome!
@WardenMilkman
@WardenMilkman Жыл бұрын
I spent 4 days trying to figure it out but after your tutorial it worked 👍🏻
@SpeedTutor
@SpeedTutor Жыл бұрын
Awesome, I'm glad I could help you out! :D How did you find my tutorial?
@user-uc9vv4ey2v
@user-uc9vv4ey2v 3 жыл бұрын
Great method. However, one slight issue is that you can spam click your open/close key to trigger the animation. I fixed this by adding two animation states; open and closed- both obviously having an idle position for the closed and opened door. Then, I check to see if the door is in one of these animation states before opening/closing the door: if (yourAnimator.GetCurrentAnimatorStateInfo(0).IsName("opened") || yourAnimator.GetCurrentAnimatorStateInfo(0).IsName("closed") { //Open & Close your door } Hope this helps!
@SpeedTutor
@SpeedTutor 3 жыл бұрын
That's great to hear! I did make an update to my "Door Interaction Kit" which has an example of how to stop being able to spam the animations, I think I even updated this in the recent door videos too! :) Thanks for the suggestion though!
@stingandr
@stingandr 2 жыл бұрын
where do i paste that? in what line of the code?
@pabloperezmartin1906
@pabloperezmartin1906 3 жыл бұрын
Great tutorial! Could you explain briefly how to set the intermediate script so we can use several objects with different uses? That would be just fantastic if you could. Thankss from spain
@dariusjackson1960
@dariusjackson1960 2 жыл бұрын
THANK YOU, MY FINAL ASKED ME TO DO THIS. U SAVED ME
@SpeedTutor
@SpeedTutor 2 жыл бұрын
I'm really glad I could help you out! :D
@gmangman123
@gmangman123 Жыл бұрын
very good tutorial! I use this method for shooting with raycast ammo crates break!
@SpeedTutor
@SpeedTutor Жыл бұрын
Oh awesome, good job! :D
@ElectricZoel
@ElectricZoel 3 жыл бұрын
Love your videos!
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Thanks very much! :)
@ElectricZoel
@ElectricZoel 3 жыл бұрын
Your free assets are awesome!
@ElectricZoel
@ElectricZoel 3 жыл бұрын
I'm making a survival fbs game... I used two of your free assets... They work great!
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Which ones did you use? Thanks very much though! :)
@ElectricZoel
@ElectricZoel 3 жыл бұрын
@@SpeedTutor I used the full menu system and the battle royal system.
@parthacodes5893
@parthacodes5893 Жыл бұрын
Thanks a lot it helped in my project most of stuff dont have doors only the palace has it
@SpeedTutor
@SpeedTutor Жыл бұрын
Great to hear it, thanks for checking this out! :))))
@Dan-ed1sk
@Dan-ed1sk 2 жыл бұрын
got it working, must be careful to follow exactly!
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Yes, absolutely! That's the trials and tribulations of programming, haha. Good work!
@EnriqueIMMontemar
@EnriqueIMMontemar 2 жыл бұрын
it's not necessary to make 2 animations for the door, you can just copy the open animation in the animator and put the speed as -1
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Great advice, I realised this in my more recent examples of opening doors. I do show that in my other animation style tutorials, thanks for sharing though! :)
@EnzoGOAT
@EnzoGOAT 3 жыл бұрын
Thank you SpeedTutor ! :)
@SpeedTutor
@SpeedTutor 3 жыл бұрын
No problem at all! :)
@th3e_m4ng0
@th3e_m4ng0 2 жыл бұрын
This WORKED PERFECTLY! Thank you SOO much!!
@DavidEclipse
@DavidEclipse 2 жыл бұрын
usa un ontriggerEnter
@darkdoom907
@darkdoom907 2 жыл бұрын
thanks again sire
@SpeedTutor
@SpeedTutor 2 жыл бұрын
You're very welcome, Knight Doom.
@darkdoom907
@darkdoom907 2 жыл бұрын
@@SpeedTutor :)))))
@kingdoom1906
@kingdoom1906 2 жыл бұрын
Thank you
@SpeedTutor
@SpeedTutor 2 жыл бұрын
You're very welcome! :D
@viking805fan
@viking805fan 2 жыл бұрын
Hi there, thanks for the tutorial. Is there a way to make a laser (Line Renderer) trigger the door to open instead of player input by the use of a trigger box collider?
@SpeedTutor
@SpeedTutor 2 жыл бұрын
I'm not sure what you're asking here, isn't this the same thing?
@rave_gamez5963
@rave_gamez5963 3 жыл бұрын
hey speed tutor thx for this tutorial but i have a error whenever i click on the door it keeps playing the open door animation like i can close it but it still plays out the open animation
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Is this error from the tutorial on my pack online?
@Gowy_YT
@Gowy_YT 2 жыл бұрын
TYSM!!!!!
@SpeedTutor
@SpeedTutor 2 жыл бұрын
That's no problem at all! :)
@dcry1003
@dcry1003 Жыл бұрын
hey just wanna ask can this also be applicable without the use of a mouse click? like with just a raycast after finding a gameobject with a specific layer it would trigger the gameobject specific action?
@SpeedTutor
@SpeedTutor Жыл бұрын
You could, just remove the input part and it would activate the action without it :)
@frankdekorte1901
@frankdekorte1901 3 жыл бұрын
Hi, thank you fot the tutorial but I am getting the warning: Animator.GotoState: State could not be found UnityEngine.Animator:Play(String, Int32, Single). Could you tell me what I should do?
@frankdekorte1901
@frankdekorte1901 3 жыл бұрын
No, not yet
@StigDesign
@StigDesign 3 жыл бұрын
Awesome :D i wonder how you could make door like they are in RainBowSix3 rave shield where you could use mouse wheel to slowly open/close door hehe :D what i think might be a way not efficent but, is some how each rotation angel and use inc& dec the rotation angel as long as it is within threshold also local rotation :D
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Exactly! That's why I imagine you'd do it! Depending on your input of the mouse wheel, you'd increase the angle by 10 degrees each time! :)
@StigDesign
@StigDesign 3 жыл бұрын
@@SpeedTutor :D
@fanvila6533
@fanvila6533 3 жыл бұрын
Thank you and I have a question about the door, there is no error on Unity and visual studio, however, when I get into the game, the door can be opened but after that, it will automatically open and close, is there still have some error in cording??
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I'm not sure what your script looks like? You can download my free door pack on the asset store if you want to check against your code! :)
@fraiva22
@fraiva22 6 ай бұрын
when do we write the doorcontroller script. its referenced in doorraycast
@ax4mineshaft844
@ax4mineshaft844 4 ай бұрын
Hi, where did u get ur FPSController and MainCamera game objects from? I have followed the tutorial closely but mine doesnt work. (Crosshair unresponsive, animation and door not interactable) I got my FPS controller from the unity asset store but it looks different from yours. I suspect that I have attached my scripts to the wrong objects.
@SpeedTutor
@SpeedTutor 4 ай бұрын
It's the Unity standard assets but controllers are built slightly different depending on what you've got hold of :)
@ax4mineshaft844
@ax4mineshaft844 4 ай бұрын
@@SpeedTutor Would the FPSController in this video be the same as the one in ur FPS controller tutorial 2 months ago?
@hh5559
@hh5559 7 ай бұрын
I typed out the exact code as you, but for some reason, every time I try going near the door, it keeps bringing up a bunch of errors in the console saying 'Tag: InteractiveObject is not defined', despite there being no errors in the code. The crosshair shows up fine but won't let me click and open the door.
@SpeedTutor
@SpeedTutor 7 ай бұрын
That suggests you haven't set the tag in the top right of the inspector :)
@Gamer-Niche
@Gamer-Niche 3 жыл бұрын
So can you please explain how to let the animation finish first before you could close the door. I have been searching for solution but its to complicated for this code. I think that the only issue. Please help thanks
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You can download my "Door Interaction Kit" and there is an example in there for you! :) I updated it since this tutorial!
@rave_gamez5963
@rave_gamez5963 3 жыл бұрын
many people don't appreciate his tutorial
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I hope you appreciate it! :)
@aus_bot9899
@aus_bot9899 3 жыл бұрын
The code is good now I thinks but whenever i try to change the tag the right ones aren't there
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You can add new ones
@Lexmon.
@Lexmon. Жыл бұрын
for some reason the raycast script isnt working properly (using the code from your patreon) Tag: DoorButton is not defined. cs:32
@filipdimitrievskicosmicvis7363
@filipdimitrievskicosmicvis7363 2 жыл бұрын
Yo, this is very cool but i found a moment lacking witch i think is quiet hard to make, but would you like to explain how to make the door not start the close animation all the way from the beginning if clicked on half open door. Thanks
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Oh you would need to create a boolean to check when it is open or closed, then when you click you need to check if it's all the way open or not. I think I cover that in one of more recent videos about opening doors. Maybe the key one? :) You should check that! :)
@TomFowkes
@TomFowkes 2 жыл бұрын
most of it worked for me except two things, at 16:16 there was no option for InteractiveObject in the dropdown menu for the tag and at 16:40 there was no option for 'Interact' on the dropdown menu for the Layer Mask Interact. great tutorial though, and it would be very appriciated if you could help with my issues. thanks
@SpeedTutor
@SpeedTutor 2 жыл бұрын
You need to create those tags and/or layers yourself via those dropdowns by "Add tag"! :)
@virtuosogames3664
@virtuosogames3664 3 жыл бұрын
I followed your tutorial exactly and when I left click on the door, the door goes from idle > door close animation when the door is already closed and it never plays the door open animation. I'm not sure what is going on with it.
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You could download my door interaction kit and compare the code?
@roymgr
@roymgr Жыл бұрын
Hello, I want to thank you for this video and the one about the door with the key, they have helped me A LOT, but I have a question, I'm starting with programming and I don't have much idea what to do, and I wanted to know if you could help me How can I do this but with a button, it's for an Android project haha PS: Sorry if it is not understood but I am using the translator xd
@SpeedTutor
@SpeedTutor Жыл бұрын
I have a tutorial on creating a button, or do you mean a UI button? If so, I have a tutorial on UI buttons too! :)
@tranceemerson8325
@tranceemerson8325 3 жыл бұрын
this tutorial has a lot of extra stuff I don't need. like the crosshair stuff... is there a version of the code that doesn't deal with that?
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You can just delete those lines! :)
@harvey1839
@harvey1839 3 жыл бұрын
hi man, thank you so much, it works perfectlly, but is it posibble to put a sound when it open and close
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Yes! Just play an audio clip when you play your animation. Just google how to play on audio clip, it will be "PlayOneShot" :)
@harvey1839
@harvey1839 3 жыл бұрын
Wow Amazing, that's great, thank You man, you're very kind
@dunderguy
@dunderguy Жыл бұрын
This works great but what if I want multiple doors without having to create a separate animation for each door? When I duplicate the door it just snaps back to the original's position when I open it instead of playing the animation where the duplicate is. (if that makes any sense)
@SpeedTutor
@SpeedTutor Жыл бұрын
Did you set the position of the animation? Make sure to just affect the rotation, would that fix the issue? :)
@iakacer
@iakacer 3 жыл бұрын
Amazing tutorial, I'm having issues with the crosshair part, I've changed to a text "[E] Open Door", and the text kept flashing somehow, it is the same with the crosshair color too.
@SpeedTutor
@SpeedTutor 3 жыл бұрын
In what way do you mean flashing?
@iakacer
@iakacer 3 жыл бұрын
@@SpeedTutor For example, in your demo with the original script, the crosshair is flashing red instead of a static red crosshair when aiming at the door.
@SpeedTutor
@SpeedTutor 3 жыл бұрын
That's strange, did you write the correct if statements within the update method? You could download my pack and see for yourself! :)
@iakacer
@iakacer 3 жыл бұрын
@@SpeedTutor Thank you for all the tutorials, I managed to solve the issue by modifying your script. :D it's now working perfectly fine.👍👍
@ericmiyan3466
@ericmiyan3466 3 жыл бұрын
i dont get any error but the animations just wont play even when i set open door to default the door doesnt move
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Does the animation play when you try it in the inspector?
@muhammadabdullahkhan5
@muhammadabdullahkhan5 2 жыл бұрын
Hi, Can you help me a little bit how do I set my tag to interactive object and how to set layer to raycast ?? BTW Thanks for tutorial
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Just at the top of the inspector, there are tags and layers. You can click the drop down and choose to add a new tag or layer. Then in the boxes which appear, add a new one in a blank area! :)
@BlobAlt
@BlobAlt 4 ай бұрын
I know how to make an animated door but the problem is that the door bugs out if i rotate it, because animation isnt additive instead it just sets the door rotation to 0,0,0 and changes it to 0,90,0 . Any help?
@SpeedTutor
@SpeedTutor 4 ай бұрын
If you tick "Root Motion" on the animation component for the door, that could help :)
@BountyIn4K
@BountyIn4K Жыл бұрын
for the [SerializeField] private Image crosshair = null; its mad at me for just putting Image, do you have any idea why? CS0246.
@SpeedTutor
@SpeedTutor Жыл бұрын
Did you add the "UnityEngine.UI" to the top? As one of the namespaces?
@BountyIn4K
@BountyIn4K Жыл бұрын
@@SpeedTutor ahhhhhhhh I didn’t, okie thanks a lot!!
@SpeedTutor
@SpeedTutor Жыл бұрын
You're very welcome! :D
@wecontrolyourinsanity1378
@wecontrolyourinsanity1378 Жыл бұрын
This really helps and is great but one small issue I have is that why does my animation for closing the door and opening the door keep on looking even though loop time isn't checked?
@SpeedTutor
@SpeedTutor Жыл бұрын
You're sure that loop time isn't on for specific animations? You don't have multiple, do you?
@wecontrolyourinsanity1378
@wecontrolyourinsanity1378 Жыл бұрын
​@@SpeedTutor Thank you so much
@sneackmear78
@sneackmear78 3 жыл бұрын
Thx
@SpeedTutor
@SpeedTutor 3 жыл бұрын
No problem!! :)
@crafthuntofficial
@crafthuntofficial 2 жыл бұрын
can i add a cooldown before i use the door again? Because if i keep spamming it just repeats the animation in the middle of the other animation
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Yes, I do actually have a cooldown in one of my more recent door opening videos. Maybe the key one? :)
@crafthuntofficial
@crafthuntofficial 2 жыл бұрын
@@SpeedTutor Ok i'll check it out
@mikk86
@mikk86 3 жыл бұрын
Hei SpeedTutor, its me again :) Thank you for your last answer again. Do you have any quick idea of how to prevent the multi clicking on the door and prevent restarting the function? Thanks :)
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You could create a little cooldown timer, using a co-routine each time you click it. Set a boolean true when it's clicked, set it to false in the cooldown and check that boolean in the code when you click or play the animation! :)
@mikk86
@mikk86 3 жыл бұрын
@@SpeedTutor Thank you very much again:)
@spiderdlh9905
@spiderdlh9905 3 жыл бұрын
Hi im getting this message The referenced script (Unknown) on this Behaviour is missing! and no animation just allows me to walk through the door
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You could download my pack from the store and check it against yours, that might be helpful? :)
@swagtrapswag
@swagtrapswag 5 ай бұрын
Followed the entire video yet mine does not work Here are my problems. In the door raycast script. I am missing both the keycode and image properties.. I have looked through your code several times and it is completely identical. Which means I am unable to continue on to the testing phase. As well as an error in the console stating CS1002: ";" expected. Again I have looked through the code and nothing is wrong. Can you help me?? every other door tutorial is too hard and I just cannot look again
@SpeedTutor
@SpeedTutor 5 ай бұрын
Paste the lines of code that are related to the error and I'll see :)
@mustard-223
@mustard-223 2 жыл бұрын
it's okay if this never gets seen, it's not a great place to be asking it got the tutorial working with no issues, although I do have a question. I want to have several types of interactive objects, including chests and dresser drawers as well as doors. I got my chest animations made, but I can't get anything to work for the life of me. I honestly don't know if I should be putting any additional animations in the playAnimation function of the myDoorController script, or if there should be different logic in the doorRaycast that references a separate chest script. in any case, right now I can't get the chest to animate at all, even though I do get a crosshair color change thanks again for the awesome tutorial, regardless if this gets seen or not
@SpeedTutor
@SpeedTutor 2 жыл бұрын
It's hard to know of your implementation for this but if you're just using the raycast to play a script on each object that players an animation. If you make sure the correct animation is being played in each case, shouldn't it work?
@tesoro23b
@tesoro23b Жыл бұрын
is it possible to make this script universal? that is, not only for the door, for example, for a pull-out shelf?
@SpeedTutor
@SpeedTutor Жыл бұрын
Of course, you'd just play the animation on the drawer instead of playing the door animation! :)
@tesoro23b
@tesoro23b Жыл бұрын
@@SpeedTutor thanks)
@bmpproductions
@bmpproductions Жыл бұрын
This probably has a simple answer, but... I really need to know how to get multiple doors and objects to have their respective animations work when clicked on. Example: I have multiple working doors but I have another object with cabinet doors that have different animations. Would that be able to be accessed through the DoorController script or will I need to make a separate one for that. If you can, explain what I could do here, please and thank you.
@SpeedTutor
@SpeedTutor Жыл бұрын
I can't fully remember how I coded this but the best way is to create one script which controls playing animations or use "Events" so you can play specific animations on objects with one script. You can check out my tutorial on events, this means all objects have the same script but like UI buttons, have events where you can do whatever action you want :)
@saihou1280
@saihou1280 Жыл бұрын
what i did was use the same raycast code but change the controller
@bmpproductions
@bmpproductions Жыл бұрын
@@saihou1280 I eventually just made a [serializedfield] for the animation names and just input the names of each type of animation into the inspector. That was like the first thing that came to mind to fix my problem.
@codyalmgren5903
@codyalmgren5903 2 жыл бұрын
Very good tutorial. I have a question. My crosshair doesn't change color and my door won't open. I've looked over the code but can't find any errors. I then tried to find your door kit on the asset store but couldn't find it. Did you happen to remove it?
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Oh my door pack is on my Patreon now, only those who downloaded my door kit before will still have it on the Unity Store. As to your question, did you tag the door and give it a layer? Do you get any errors?
@codyalmgren5903
@codyalmgren5903 2 жыл бұрын
@@SpeedTutor Tysm for the help. The only error I get is "Animator.GotoState: State could not be found UnityEngine.Animator:Play (string,int,single)"
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Did you upload the name of your animation in the inspector to the one you created? :)
@codyalmgren5903
@codyalmgren5903 2 жыл бұрын
@@SpeedTutor thank you so much I just forgot to do that :)
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Luckily someone had that issue just a little earlier than you! Haha. So I knew the fix! :P Thanks for watching.
@FoxGAMING-NTF
@FoxGAMING-NTF 3 жыл бұрын
I can't seem to be able to get this to work for me, the crosshair will never change, either. I tried getting your Free Door Interaction Asset on the Unity Asset Store, and it would work for the prefab doors, but not for what I'm trying to use it on/ for, which is a trash can door. It's supposed to be so that you can look at the door, and then left click on it to open / close the door / lid. Edit / Update: Ok, so I'm just dumb, all I needed to do was make the Box Collider a bit bigger. Another Edit: Ok, Maybe not, I can't get it to work again anymore. Another (Hopefully, I guess, Final,), Update: Ok, so I think it actually is that. It (the Box Collider,), has to be the height of my player or something, in order for it to detect it. I guess, in this case, is there a way to make it be so that I don't have to make the Box Collider so big that it will obstruct other collisions? The trash can in question (and all of them, probably, for that matter,), have another box collider for being able to drag the trash can around, and this Box Collider, with the fact that it has to be so big, means that it collides with the box collider for this. Plus, it makes the spot you have to look at the trash can door / lid for very unrealistic / inaccurate / big.
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I'm not really sure what to suggest because I've never had to make the box collider bigger than the player, you can normally do it on a tiny little object. Are you using it in a first person style?
@FoxGAMING-NTF
@FoxGAMING-NTF 3 жыл бұрын
@@SpeedTutor Yes, I'm trying to make / use a full-body FPS Setup. I'm using FirstPersonAIO (First Person All-in-One). It seems, that the collider has to be the height of the player, or at least, up to the height of the player camera.
@FoxGAMING-NTF
@FoxGAMING-NTF 3 жыл бұрын
@@SpeedTutor I'm also trying to figure out how to make the player character's head move with the camera. Currently, I have the player camera as a child of the DEF-head bone, and the head bone has a script attached to it to make it follow the camera, but it makes the camera jitter, shake, and wobble, quite a lot. And, it seems as if the camera moves at a different, faster speed than the head, and the head can twist too far. It only makes the head move up and down, since because I think it's since I'm using the FirstPersonAIO System, and I have the player character mesh as a child of the FPSAIO Controller, so it rotates the body left and right when you look left and right. But still, there needs to be a limit to the angle of rotation that the head can make, and I need to figure out a way to make the camera and head move at the same speed, and look at the same angle.
@JustJoshinYouBro
@JustJoshinYouBro 7 ай бұрын
How do I make it so the crosshair is never active until I look at an interactable object.
@SpeedTutor
@SpeedTutor 7 ай бұрын
Make the interaction only happen when you're using the tag :)
@miracube4452
@miracube4452 3 жыл бұрын
hey, I've followed your tutorial exactly how you did it, but nothing works. no errors or anything, all scripts are attached, but my crosshair doesnt change colour nor can i open/close the door. do you have any ideas as to what might be the problem?
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I'm not sure at all, you could download the pack from the store and check it against yours? :)
@hsmyv
@hsmyv 3 жыл бұрын
same problem(
@Dan-ed1sk
@Dan-ed1sk 2 жыл бұрын
me too
@xEVANcMAN
@xEVANcMAN 2 жыл бұрын
Same
@dogepauwa2770
@dogepauwa2770 2 жыл бұрын
@@SpeedTutor I like how you make a video about something and when someone says they have a problem you tell them to buy ur shit? absolute sellout unsubscribed.
@uduarteextras
@uduarteextras Ай бұрын
How do I add sound for opening and closing doors?
@SpeedTutor
@SpeedTutor Ай бұрын
I actually have a tutorial on that, you'll find the link in the description :)
@tesoro23b
@tesoro23b Жыл бұрын
is this way of opening the door the same as in granny, outlast, hello neighbor?
@SpeedTutor
@SpeedTutor Жыл бұрын
How do those work?
@tesoro23b
@tesoro23b Жыл бұрын
@@SpeedTutor yes
@Kraizelle
@Kraizelle 3 жыл бұрын
For some reason, i am getting the following error: Tag: InteractiveObject is not defined. UnityEngine.Component:CompareTag(string) I've tried everything but I can't make it work
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Did you create it in your tags?
@chrestycs
@chrestycs 2 жыл бұрын
I got a problem with the raycast, the error says: Assets\MyDoorRaycast.cs(15,30): error CS0246: The type or namespace name 'Image' could not be found (are you missing a using directive or an assembly reference?). Then i added a canvas with a child named Image that is the crosshair, and still doesn't works. I don't know if it's because I didn't got my FPS of your channel of something. Please help me
@chrestycs
@chrestycs 2 жыл бұрын
Would you please give me the script without that or something to fix it?
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Did you add "Using UnityEngine.UI" to to the top?
@chrestycs
@chrestycs 2 жыл бұрын
@@SpeedTutor what's that?
@SpeedTutor
@SpeedTutor 2 жыл бұрын
A namespace to access all the UI scripting references, you'll need :)
@3dprint_object
@3dprint_object Жыл бұрын
why is it showing me this error: the type or namespace name 'MyDoorController' could not be found. Please answer quick.
@SpeedTutor
@SpeedTutor Жыл бұрын
Is your script name and class name the same?
@xzctrwesfsd
@xzctrwesfsd 9 ай бұрын
But what if I have more than 1 door in my project? I need to create new MyDoorController and DoorRaycast scripts with different int-s? Is there not an easier way?
@SpeedTutor
@SpeedTutor 9 ай бұрын
No, you can just use the same scripts on each door :)
@xzctrwesfsd
@xzctrwesfsd 9 ай бұрын
That didn't work for me but I've found a fix, if anyone else is having this question in 2023 - Instead of having a single raycastedObj variable, change it to an array or a list to store references to multiple doors. e.g. private List raycastedDoors = new List(); and then update the logic in the "Update" function to handle multiple doors according to that change. Don't forget to give your new animated doors/windows/curtains interactable tag and switch Layer to Interact.
@amrutsiroya2582
@amrutsiroya2582 2 жыл бұрын
How can I make a goalkeeper ai
@hurricaneblackandwhite1219
@hurricaneblackandwhite1219 2 ай бұрын
after following all the steps i have gotten stuck on 4 errors about the color, Vector3.foward, Raycast, and forward by itself telling me the namespace isn't found any help would be great
@SpeedTutor
@SpeedTutor 2 ай бұрын
Is the class name the same as the script name. Have you made sure all the capitals are you in the correct places?
@hurricaneblackandwhite1219
@hurricaneblackandwhite1219 2 ай бұрын
@@SpeedTutor i figured it out thank you
@SpeedTutor
@SpeedTutor 2 ай бұрын
What was the solution?
@litovizija
@litovizija 2 жыл бұрын
What if for me everything is working fine, but when i put my crosshair on door its not turning red, but its working
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Maybe you're missing the tag? Collider? Anything like that?
@ThePolandEngineer
@ThePolandEngineer Жыл бұрын
i got two errors saying: error cs8805 program using top-level statements must precede namespace and type declarations error cs1022 type or namespace definition or end-of-file expected please help
@ThePolandEngineer
@ThePolandEngineer Жыл бұрын
i fixed it but i got more errors :(
@SpeedTutor
@SpeedTutor Жыл бұрын
What errors?
@ThePolandEngineer
@ThePolandEngineer Жыл бұрын
@@SpeedTutor nevermind, i fixed it
@Wesley3268
@Wesley3268 Ай бұрын
the problem with me putting up raycast is when I wrote the code even if I copy pasted it, I NEVER GET IT TO WORK. I either got 100+ errors, or a null reference exception.
@SpeedTutor
@SpeedTutor Ай бұрын
I have all the scripts on my Patreon but try and work through your errors because it's a fantastic way to learn, I know it's annoying.
@pyth0n539
@pyth0n539 3 жыл бұрын
I keep getting the error "; Expected" but i have the ";" at the end int mask 1
@bluntfist
@bluntfist 3 жыл бұрын
int mask = 1
@pyth0n539
@pyth0n539 3 жыл бұрын
@@bluntfist Haha, thank you :)
@iamgavinsmith
@iamgavinsmith 3 жыл бұрын
I keep getting NullObjectReference Exception errors. Why is this happening? The door works, but I still get the errors.
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Are you just following along with my tutorial? No other scripts are involved?
@iamgavinsmith
@iamgavinsmith 3 жыл бұрын
@@SpeedTutor Yes
@Gaz_Game
@Gaz_Game 3 ай бұрын
Can anyone help me out? When I press "E" at the door it's as if the animation plays but my door isn't actually moving? the crosshair goes white if i look at where the door is not if the animation had actually played.
@SpeedTutor
@SpeedTutor 3 ай бұрын
Is there a collider and tag on the door?
@Gaz_Game
@Gaz_Game 3 ай бұрын
@@SpeedTutor My door object was checked on so I unchecked it and it works fine now! However, I have now noticed that if I spam the button the animation ends with the door rotating out of position?
@littledarkage1-964
@littledarkage1-964 3 жыл бұрын
I instantiate multiple doors in my project, but instead of the door prefab I click, or any door in the scene, only one specific door prefab (the first one to be instantiated) animates. Do you have any idea what might cause this issue? Thanks in advance.
@littledarkage1-964
@littledarkage1-964 3 жыл бұрын
In this part, if I don't put one of the comment lines, it gives null reference error. If I put one of these, it animates the first prefab instantiated like I mentioned previously. Not sure what to do at this point. if (Input.GetKeyDown(openDoorKey)) { //raycastedObj = GameObject.FindWithTag("doorTag").GetComponent(); //raycastedObj = GameObject.Find("doorNew(Clone)").GetComponent(); raycastedObj.PlayAnimation(); }
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I'm not really sure what to suggest to you. :( Could you untie those prefabs?
@littledarkage1-964
@littledarkage1-964 3 жыл бұрын
Not sure what you mean exactly. Thanks for the amazing tutorials by the way.
@SpeedTutor
@SpeedTutor 3 жыл бұрын
As in, unpack the prefab when you start? (And) Thanks very much, I'm glad it was helpful to you! :)
@littledarkage1-964
@littledarkage1-964 3 жыл бұрын
@@SpeedTutor The problem was about my prefab structure. The raycast hit wasn't seeing my prefab's box collider because of some scaling issue in my code, box colliders were occuring somewhere irrelevant. In my previous comment, the code's comment lines caused referencing the first occuring door prefab in the scene for the raycasted object, therefore only that door was being animated no matter which door was clicked. I just wanted to explain for anyone who might have similar issues, and wanted to thank you again, for your tutorials and your willingness to help everyone in the comments.
@ndnd1915
@ndnd1915 3 жыл бұрын
Is there a way to add multiple different doors into the DoorRaycast script?
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Yes, you'd want an intermediate script which controls what types of doors you can choose from and depending on the tag or type you find, you can do some functionality! :)
@viktorkuska3286
@viktorkuska3286 3 жыл бұрын
@@SpeedTutor Hey! Amazing tutorial, very clear, I'm really interested in being able to open multiple doors, but am not managing, I'm not very familiar with C# and just need this for a personal "project", would you be able to link some code which can be implemented with the code used here?
@tristoncooley9402
@tristoncooley9402 Жыл бұрын
For the serialize fields its telling that they are valid in this context. I have them typed exactly as you have them.
@SpeedTutor
@SpeedTutor Жыл бұрын
Do you have errors elsewhere?
@tristoncooley9402
@tristoncooley9402 Жыл бұрын
Yeah. The layermasks bits of code towards the bottom are also throwing an error. ExcludeLayerName and fwd.transform, raylength as well. And now upon reloading instead of the serialized field throwing an error its the private right after.
@benarbiaoussama3152
@benarbiaoussama3152 3 жыл бұрын
Hi i have probleme NullReferenceException: Object reference not set to an instance of an object DoorClosetRayCast.Update () (at Assets/Scripts/DoorClosetRayCast.cs:72)
@SpeedTutor
@SpeedTutor 3 жыл бұрын
What's on line 72?
@vincentjohansson2002
@vincentjohansson2002 3 жыл бұрын
@@SpeedTutor I think he means 42 because I get the samething
@vincentjohansson2002
@vincentjohansson2002 3 жыл бұрын
@@SpeedTutor soory 44 it was
@user-vl5us3io7b
@user-vl5us3io7b 7 ай бұрын
Thanks for the great tutorial. I am typing this text with automatic translation, so I apologize if some parts are incorrect. I was able to get to the point where I could open and close the door with your tutorial, but I am having trouble with the door hit detection and it just slides through. If you could please tell me how to solve this problem, I would appreciate it.
@SpeedTutor
@SpeedTutor 7 ай бұрын
Can you explain a little more, it slides through? As in doesn't detect the door? :)
@user-vl5us3io7b
@user-vl5us3io7b 7 ай бұрын
@@SpeedTutor Thank you for your prompt reply. I have already solved the problem I mentioned earlier. So, one question: may I sell the game that implements the door feature that I made based on your tutorial on steam and other sites? In a nutshell, "May I use it for commercial purposes?" This is what I mean.
@SpeedTutor
@SpeedTutor 7 ай бұрын
Yes, absolutely. You're free to use them, as long as you don't sell it by itself. If it's part of a game, that's fine :)
@user-vl5us3io7b
@user-vl5us3io7b 7 ай бұрын
@@SpeedTutor Thank you so much. We will introduce you in the credits of the end roll of the game.
@synth3tic256
@synth3tic256 2 жыл бұрын
I cant add the DoorRaycast script onto the Camera and it Says because the script class cannot be found.
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Is the script name the same as the class name?
@pounceroreo2
@pounceroreo2 2 жыл бұрын
I have this same issue. Tried yesterday.
@synth3tic256
@synth3tic256 2 жыл бұрын
It does but it still says the same thing.
@SpeedTutor
@SpeedTutor 2 жыл бұрын
You fixed it?
@gasparo8907
@gasparo8907 2 ай бұрын
I had my doors marked as static for light baking purposes. Doors won't move when marked static...
@SpeedTutor
@SpeedTutor 2 ай бұрын
That's right, if it's static it won't move at all. You need to make sure they're not because it's for things that never move :)
@gasparo8907
@gasparo8907 2 ай бұрын
​@@SpeedTutor Great tutorial.
@SpeedTutor
@SpeedTutor 2 ай бұрын
Thanks very much :)
@awsumturtle
@awsumturtle 3 жыл бұрын
It worked but i'm having the problem that when you spam click the door it does some weird things. I've tried the fix from below but since my code is a bit different it's not working.
@SpeedTutor
@SpeedTutor 3 жыл бұрын
In my more recent door tutorials and my Door interaction kit, I show you how to sort that issue! :)
@awsumturtle
@awsumturtle 3 жыл бұрын
@@SpeedTutor I figured it out by myself, I dont know if its good code but i decided to add an ienumerator that waits a second before a bool is set to true that controls whether you can open/close the door.
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I think that's what I did, you can check out my free kit on the store and see if it's the same! :)
@zprey8385
@zprey8385 2 жыл бұрын
how to choose a range to player can interact in that range ?
@SpeedTutor
@SpeedTutor 2 жыл бұрын
The ray distance? Or Ray length? In the raycast script, I can't recall what I used. :)
@George-wc3hg
@George-wc3hg 3 жыл бұрын
Hey might be a very dumb error, But my door is animating constantly. And im not exactly sure why.
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You don't have this in update, do you?
@George-wc3hg
@George-wc3hg 3 жыл бұрын
@@SpeedTutor I Copied everything exactly as shown. Every function is good.
@youkings100
@youkings100 2 жыл бұрын
But what if there are multiple doors in a scene if they all use the same anim controller wouldn't they all open? How would I avoid this?
@SpeedTutor
@SpeedTutor 2 жыл бұрын
No, because they play as different instances :)
@youkings100
@youkings100 2 жыл бұрын
@@SpeedTutor Oh cool good to know, thanks :)
@danielfenton1686
@danielfenton1686 2 жыл бұрын
7:47 Can someone help me please? When doing the "Raycast hit;" part of the code, the word 'Raycast' automatically turns to 'RaycastHit' and when I then delete the 'Hit' part, the word 'Raycast' remains in white text. Why is this? It appears it doesn't have a Raycast to reference.. Am I missing something here?
@SpeedTutor
@SpeedTutor 2 жыл бұрын
What does your code look like?
@yoko3021
@yoko3021 Жыл бұрын
It's supposed to be RaycastHit hit; he corrects it a minute later.
@mxbshr4276
@mxbshr4276 Жыл бұрын
i managed to get this working but the crosshair doesnt go red for some reason?
@SpeedTutor
@SpeedTutor Жыл бұрын
That's very strange, do you have the correct tags?
@mxbshr4276
@mxbshr4276 Жыл бұрын
@@SpeedTutor yeah all the tags are correct on the door, InteractableObject and Interactive
@lisannelin2872
@lisannelin2872 3 жыл бұрын
How do I do this when the door is a child of an empty game object, which I used for changing the pivot point?
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You could make a collider over that empty game object and scale it out? :)
@lisannelin2872
@lisannelin2872 3 жыл бұрын
@@SpeedTutor Thanks, I will try it!
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Good luck! :)
@borka2984
@borka2984 2 жыл бұрын
@@SpeedTutor thank you!! It worked
@xEVANcMAN
@xEVANcMAN 2 жыл бұрын
Hi SpeedTutor. I copied exactly as in the vid and some reason my door wont open and the cross hair never changes color. The only difference in our scripts is at one point you used Raycast hit; but thats a compiler error for me so i used RaycastHit hit; dont know if thats why its broke but if anyone can help itd be huge help!
@SpeedTutor
@SpeedTutor 2 жыл бұрын
No you're right, I probably made a mistake in the code during the video and changed it later. Did this tutorial need tags or layers for the door? Any errors?
@xEVANcMAN
@xEVANcMAN 2 жыл бұрын
@@SpeedTutor i tagged the door as interactive object tag that i made spelled the same as code and the layer is interact too. But it dont work. Appreciate any help
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Does your door have a collider on it? Nothing blocking that collider? Did you set the layer in the raycast script in the inspector?
@xEVANcMAN
@xEVANcMAN 2 жыл бұрын
@@SpeedTutor yea man both of those are done. Would it be because iv had to use RaycastHit hit; where you somehow used Raycast hit; that gives me an error as Raycast is not a class for me
@xEVANcMAN
@xEVANcMAN 2 жыл бұрын
Also iv had to use a empty game obj for the pivot but that doesnt need the scripts or animator does it? Think i tried both anyway but maybe youd know
@magplay15
@magplay15 Жыл бұрын
i can't put raycast function in my code, i don't know why
@SpeedTutor
@SpeedTutor Жыл бұрын
What do you mean, exactly? :O
@Wabbaxt
@Wabbaxt 3 жыл бұрын
How could you and functioning ui to it ?
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I'm not sure what you mean?
@Wabbaxt
@Wabbaxt 3 жыл бұрын
i mean like when you look at the door it says (press E to open) and when open and you look at it again it says (press E to close)
@nightcoreukp5479
@nightcoreukp5479 2 жыл бұрын
Everything worked except for the animations. Raycast is working an the crosshair is turning red, but the door animation is not playing. I don't know how to fix this. Also this is a great video 👍
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Thanks my friend, your door isn't static is it? Did you give the animation the correct name?
@nightcoreukp5479
@nightcoreukp5479 2 жыл бұрын
@@SpeedTutor now I think about it door is not set to static. Thank you 👍 I will now fix it👍
@EltonOliveiradrknss
@EltonOliveiradrknss 3 жыл бұрын
What does the pipe ( | ) do? I didnt understand and also didnt find any answers
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Two of those together, usually mean (OR) So lets say: if(myInt == 1 || myInt == 7) { //Do something } It just means that if the number is equal to 1 (OR) 7 - The statement can be true! :)
@EltonOliveiradrknss
@EltonOliveiradrknss 3 жыл бұрын
@@SpeedTutor Thanks a lot for answering
@backture2863
@backture2863 2 жыл бұрын
I have a problem, after opening the door (everything works the) I cannot close the door anymore and the crosshair is also not turning red anymore. Can somebody help?
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Did you remove the tag or anything?
@backture2863
@backture2863 2 жыл бұрын
@@SpeedTutor No I don't think so. I also noticed that when I rotate the door the scale of the door changes, while the real scale doesn't change.
@infernogamey374
@infernogamey374 2 жыл бұрын
uhmm just checking but the problem now is that i can open and close just fine but when i try getting tru the door I can't the box collider makes me unable the walk tru there and the box collider isn't stuck with the door can anyone help me ?
@SpeedTutor
@SpeedTutor 2 жыл бұрын
You mean you can walk through the door? Is the box collider on the actual door object itself?
@infernogamey374
@infernogamey374 2 жыл бұрын
@@SpeedTutor no and that was the mistake i made it was on the wrong object so it wasn't on the door itself but more on the frame of the door what made it so the door had no collider hahah i'm pretty much a beginner with code and things i do understand things and i start making things myself but thats all thanks to vids like yours really big thx
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Haha, I'm glad it was an easy solution! :P Best of luck on your journey and thanks for coming along to watch my friend! :)
@aus_bot9899
@aus_bot9899 3 жыл бұрын
i keep getting this error whenever i try to add my RAYCAST into the player Cant Add Script cant add script component 'RAYCAST' because the script class cant be found. Make Shure there are no compile errors and that the file name and class name match. this is my code for RAYCAST using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class NewBehaviourScript : MonoBehaviour { [SerializeField] private int rayLength = 5; [SerializeField] private LayerMask layerMaskInteract; [SerializeField] private string excludeLayerName = null; private MyDoorController raycastedObj; [SerializeField] private KeyCode openDoorKey = KeyCode.Mouse0; [SerializeField] private Image crosshair = null; private bool isCrosshairActive; private bool doOnce; private const string interactableTag = "InteractibleObject"; private void Update() { RaycastHit hit; Vector3 fwd = transform.TransformDirection(Vector3.forward); int mask = 1
@SpeedTutor
@SpeedTutor 3 жыл бұрын
The name of your script is not the same as the class name, look at the top of your script it's called "Class NewBehaviour..." - Give them the same names! :)
@aus_bot9899
@aus_bot9899 3 жыл бұрын
@@SpeedTutor thanks for that
@blacklakemedia7838
@blacklakemedia7838 2 жыл бұрын
NullReferenceException: Object reference not set to an instance of an object DoorRaycast.CrosshairChange (System.Boolean on) (at Assets/DoorRaycast.cs:63) DoorRaycast.Update () (at Assets/DoorRaycast.cs:36) Can anyone Help me understand what i did wrong ?
@SpeedTutor
@SpeedTutor 2 жыл бұрын
What are on those two lines?
@blacklakemedia7838
@blacklakemedia7838 2 жыл бұрын
@@SpeedTutor 36 CrosshairChange(true); 64 crosshair.color = Color.red;
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Did you add the crosshair UI to the inspector?
@blacklakemedia7838
@blacklakemedia7838 2 жыл бұрын
@@SpeedTutor thank you. thats was it
@rafaaaaa478
@rafaaaaa478 3 жыл бұрын
I did the tutorial, but id didn't work, the crosshair changes to red, but the door don't open.
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Any errors?
@MCShvabo
@MCShvabo 2 жыл бұрын
Would this work on a 3rd person?
@SpeedTutor
@SpeedTutor 2 жыл бұрын
It could do, yes! :)
@MCShvabo
@MCShvabo 2 жыл бұрын
@@SpeedTutor I'll try it tomorrow, thanks so much!
@MCShvabo
@MCShvabo 2 жыл бұрын
@@SpeedTutor I finally got around doing it and you were right, thanks so much! Just a note for anyone who tries to do this with a 3rd person character in the future, the only difference is that you might have to make your ray length a bit higher, since it's the camera, not the player character that interacts with the object, and camera is obviously further away if you are using a 3rd person view. I had to set ray length to 9 in order to make it work but it really depends on your setup.
@ElectricZoel
@ElectricZoel 3 жыл бұрын
Can you make a free in game shop asset pack for a survival fbs game please!!!!!!
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You'd have to find me an example! :)
@ElectricZoel
@ElectricZoel 3 жыл бұрын
@@SpeedTutor A in game shop like you walk up to the shop and a shop interface pops up so you can buy stuff like new buildings and walls for Your village almost like clash of clans expect you can walk around in a 3D world.
@OmeedNOuhadi
@OmeedNOuhadi Жыл бұрын
👏👏👏
@SpeedTutor
@SpeedTutor Жыл бұрын
You're very welcome, thanks for checking this out! :)
@cgnotavailable
@cgnotavailable 2 жыл бұрын
Can somebody give me the code because i did something wrong and i dont know how to repair
@SpeedTutor
@SpeedTutor 2 жыл бұрын
What error do you get? :)
@TatsukiBaba
@TatsukiBaba 2 жыл бұрын
@@SpeedTutor me give me the scripts please
@RyanJhider
@RyanJhider 3 жыл бұрын
Hi my friend the door Collid with my character and make it fly how can a do to reduce this effect ?
@minedog4141
@minedog4141 3 жыл бұрын
If you have rigidbody on it take it off
@RyanJhider
@RyanJhider 3 жыл бұрын
@@minedog4141 I don't have any rigidbody :/ only a character controller
@minedog4141
@minedog4141 3 жыл бұрын
@@RyanJhider i meant the door
@RyanJhider
@RyanJhider 3 жыл бұрын
@@minedog4141 The door too :/
@minedog4141
@minedog4141 3 жыл бұрын
@@RyanJhider well take the character controller outta there
OPENING a DOOR using a BUTTON
18:38
SpeedTutor
Рет қаралды 23 М.
OPENING a DOOR in UNITY on TRIGGER EVENT
8:20
SpeedTutor
Рет қаралды 108 М.
Alat Seru Penolong untuk Mimpi Indah Bayi!
00:31
Let's GLOW! Indonesian
Рет қаралды 16 МЛН
孩子多的烦恼?#火影忍者 #家庭 #佐助
00:31
火影忍者一家
Рет қаралды 49 МЛН
KINDNESS ALWAYS COME BACK
00:59
dednahype
Рет қаралды 136 МЛН
How do non-euclidean games work? | Bitwise
14:19
DigiDigger
Рет қаралды 2,4 МЛН
OPENING a DOOR with a KEY! (Unity Beginner Tutorial)
20:25
SpeedTutor
Рет қаралды 34 М.
A new way to generate worlds (stitched WFC)
10:51
Watt Designs
Рет қаралды 515 М.
The Art of Game Optimization
10:18
Worlds In Motion
Рет қаралды 257 М.
EA Won't Let Me Play This Game - So I Hacked It
8:49
Nathan Baggs
Рет қаралды 293 М.
3 Ways to Open Doors in Unity!
20:55
Code Monkey
Рет қаралды 41 М.
How Do Games Render So Much Grass?
15:52
Acerola
Рет қаралды 321 М.
I Wish I Had Known This Before I Started Unity Game Development...
11:11
How To Open Doors Easily in Unity With Trigger Events
6:52
Fist Full of Shrimp
Рет қаралды 1,2 М.
Alat Seru Penolong untuk Mimpi Indah Bayi!
00:31
Let's GLOW! Indonesian
Рет қаралды 16 МЛН