#2 FPS Raycast Interactions: Let's Make a First Person Game in Unity!
HTML-код
- Опубликовано: 21 фев 2022
- The second video in the Lets Make a First Person Game series!
🖐In this video we are going to setup the foundations for our interaction system.
Come Join us on the Discord!
🎮 / discord
💚 Thanks for watching!
Helpful Links
dotnettutorials.net/lesson/te...
Hey Everyone! I have only just realised there is some footage missing from the video!!!
You may encounter the error "'InputManager.onFoot' is inaccessible due to its protection level".
if you have this error you just need to change 1 line in the InputManager script.
Change this -> private PlayerInput.OnFootActions onFoot;
To this -> public PlayerInput.OnFootActions onFoot;
Also!! at 21:26 in the AnimateCube script:
Change this -> startMessage = promptMessage;
To this -> startPrompt = promptMessage;
Apologies for the mistake!
no problemo thanks for the fixes!
thanks man!
ty very muchoo !
when did we make a door in the last episode?
@@panachedhallchannel1635 I believe the door and button and cake were made offscreen in between episodes. They are all made (or can be made effectively) out of simple 3d cubes.
of all the tutorials I have been searching so far this works for me and I thank you, keep up the good work :)
these have been the best working tutorials for me in awhile i appreciate you taking the time and effort for these
Thanks for making this amazing tutorial. I really think your channel will blow up soon! :)
Hey natty,
Really love your videos!
I have been looking for an easy tutorial for month and finally found one
Keep it up :)
Thank you for fueling my dreams on coding and game devolpment!
You must have done this for soooo long. Looks so easy when yo do it. Thanks for this series. Nice to see some advanced stuff (at least it seems so for a noob like me) and you still find time to explain most of it. keep it coming, subbed and ready!
Good stuff man, looking forward to following along with this series.
I appreciate that you take the time to show the process of building the code and explaining what many of the components do in the code. I also like your approach to naming conventions: keep names simple and explicit.
I really love your tutorials, dude !
(Waiting for new parts)
I have watched loads of tutorials to handle interactions, but this is by far the best one. Super clear and easy to understand. Thank you
I have been waiting for you to upload , thank you.
I love watching tutorials. I've taken MANY courses, including the Junior Programmer Pathway. But, every time I take a tutorial, I learn something the courses didn't teach (or at least something I don't remember), such as the Interactable script and how it acts as a template. This can greatly improve the way I develop games.
yoooo, this part is much better then previous one, thank you for this tutorial))
to the people confused about the keypad and doors: they are made out of simple shapes. go into your hierarchy and add 3d object>cube, then transform each cube into the correct shapes.
Thank you so much man! It's insane how much I learn from you! Really looking forward to more videos like these!
Hva satan boomy laver du spil? Du burde da sidde på fv og trolle XD
@@durumvfx Yea haha, går på skole med programmering og spiludvikling så det altid dejligt at lære noget nyt :D
@@boomy1 Det lyder da lækkert, håber det går godt med den der skole ;)
yess the sequal came i loved the first one and cant wait to use this guide
Thank you. This is going to be a good series. I like tutorials that make me think.
Thanks for this great series!
Thank you for the great tutorial!
WOW! Thank you - you posted this on my birthday lol. Awesome video!
Hahah Happy Birthday! I really hope you enjoyed the cake !!🎂🎂 thank you so much for watching and have an awesome day !! 🙂
Happy birthday bro
it was 2 years ago @@armando_gamer1929 💀💀
the best one so far, bravo!!
id love a tutorial on how to set up the world space prompts!
Really Good Tutorial Thank you dude
Holy Moly thank you this was awesome hope you do an Inventory System Tut in the future one of the best examples of how to Code in C# for unity
Thank you. You are an excellent teacher
Awesome video series man, really insightful! How often do you plan to upload these?
Thanks very much! I really appreciate it :) I am going to try upload more often over the coming months, I have a number of videos planned!
@@NattyGameDev I'm curious what topics you're going to cover, do you mind sharing a breakdown? I'm very interested!
This video series is a really great achievement ! Thank you for your time and effort ! I know how difficult this work is... - btw: works with UNITY 2022.3 👍
this helped me a lot thanks
Thanks. Keep it up !
Thank you so much you've been a big help
Yesss been waiting for this
We all have been :D
Thanks man and btw for animating cube I used the code from Keypad and copied it and I made 2 clips just like in the video and for the changing color I used events.
Natty can you please add a tutorial for the setup of the scene. It would be much appreciated.
agree
I am new and this is my first project and I have no clue of how he created the scene. It would be great if there was a tutorial for the scene
@@mathlab6168 Same with me, I spent an hour just playing around, just make 3d blocks, adjust the positions and scale options to make walls a door and a small block for the button
did anyone found out how to setup the scene??
@@prajanyashrestha3652 It's just a bunch of cubes that are scaled. Not that hard to make ;)
Thank you for wonderful tutorial. It is awesome that I can take this lesson for free.
By the way, I am wondering how long will it take to be able to do this by myself. I am totally a begginer and found it very complexed.
Thank you so much for this wonderful tutorial, its really great but in the first tutorial you stopped at the crouch and sprint codes, and now you have built two rooms with doors and I don’t know how to do them so is there any other video in which you explained how to do them?
in the last tutorial, the video showed us the script snippets that u needed to add, and in what .cs file each snippet went in, including line references. It also showed the additional player input actions needed to be added for sprinting and crouching.
regarding this video, to make a scene such as the one he created, u need to add cubes to your scene, and manipulate their size and position in space. Like this, you can get rectangles of any size. As for the cake that he added, well, he probably made that in Blender or something. However I, for example, created a sphere and distorted it so that it resembles a coin, since i have no means of making something more complex, unless i picked up 3d sculpting or looked for a 3d model online.
Hope this helps!
Looking forward to part 3 mate :)
Part 3 out now! :D ruclips.net/video/_UIiwzfZoZA/видео.html
really love the tutorials. I had some issues like accidental duplications of a couple scripts and not having certain things public which i found the answer to in your comment on here. I do want to know, how do you make your character start out not looking at the ground? this has been a common issue throughout my time trying to find a good character controller
Dude I have the same problem I watch that part 3 times and I still can't find what's wrong
same as lads
So i had the same problem, and after looking in some of the older Discord posts I found out it was caused by moving the PlayerInteract script into player folder. For some reason Unity duplicated the PlayerInteract script when moving this script.
to solve the issue, make sure there is no duplicate of the 'PlayerInteract' script (look in the 'scripts' folder + the newly created 'Player' folder and delete either of the files), what might help is closing VisualStudio code before deleting or moving any scripts.
Hi ive been waiting for this! Nice Quality Video man. But i have a Problem. I dont get any Errors but when i interact with the keypad it doesnt play the animation. so i tried doing a debug.log to check if its even getting the input, and yes the input works but the animation just doesnt play :/
Hey, how have you gone with this?
Does the animation work when you manually set the boolean in the animator window like in the video?
I believe it may be something odd in the animator, or with the boolean values you're passing through to there :)
srry im late but, try checking if the parameter name of the animation (in the animator on the left) has the EXACT same spelling as the one refrenced in the script.
@@TheOnlyK1ng thank you man you dont know how much u help me now!!!!!!
@@NattyGameDevcan u show us how the door?
hi, first of all i really loved the first lesson! thank you very much! but it feels like the second lesson skipped the build up for the set up making it a bit hard to follow throu. thanks in advence
Awesome video, grest tutorials, bring more interactions and transitions (gameplay, freeze controls, play anim, bring controls and gameplay). and what the name of it to I search, please. peace bro
you the man
you are the best, and plZ upload fast
I know I am late to this party but, if anyone stumbles across this and is worried about interacting with interactables through things like walls - On the 'Player Interact' Script, under distance is mask - Set this 'Default, Intractable' (select both Default and Interactable)
thank you, i was dying while reading those documents T_T
lifesaver
Thanks
Sorry can you explain what you mean, does this mean you will or won't be able to interact with things through walls if you set this?
Hi! I am a blocked after the first video, because I don't know how to make that walls😂. I am really new to unity, and this is the first tutorial that worked from the beginning to the end).
привет, ты уже разобрался? У меня точно такая же проблема...
very helpful thank euuu
Is there a way to stop the raycast from going through the wall in order to lock the door behind the player?
Thanks for tutorials, but i have question: why you dont use [SerializeField] for setupable public fields and change public to private when they dosnt used in other objects? And imo u can use this [SerializeField] on PlayerInteract field in PlayerInteract and dragndrop main camera in player to this script? Thanks for answer!
hey you look like you know scripting, i got error when he finnishes script 14:24 , error says PlayerUI does not contain a definiton for UpdateText
@@beqadolidze4539 I'm having the same issue. Did you ever manage to fix it?
you are legend thanks
Nice vid man !!!! I'm a unity noob at want to learn making a FPS game.
That's Awesome! You can do it! :D
Is it just me or at 16:54 the lines of code
doorOpen = !doorOpen;
door.GetComponent().SetBool("IsOpen", doorOpen);
appear out of nowhere,
Hah! wow.. Good pickup! yes they do come out of nowhere, it seems there was an editing error.
we talk about and implement these lines at 20:14
Apologies for the confusion! I had to crunch a bit to get this video out and I completely missed that!
Dang I did not expect a reply that fast, thanks!
no it did
yeah i saw that too! I was about to add it but then a bit later its back to normal! I was so confused 🤣
I was confused too
please could you describe what you're doing, I'm new to unity, please?
I know it's late but I had a few errors popping up(like the ones the other comments are complaining of) and fixed it by deleting the copied files in the project. When I moved the files to the Player folder, it duplicated. Just go to Scripts folder and delete the player files. That's it. Tell me if it worked :) thx
Edit: And if it still doesnt work, then save the script, open the script again from unity and check if its the same. usually it won't because the one i was working on was the cloned one. so just refresh and then check if the script is the same 🙂
oh thank god for you lol i ended up just moving everything back out of player folder and deleting the folder, because it kept saving a new copy of the script in either of the two places and it was a disaster lol thanks so much!
After importing the UI into player input, I keep getting an error saying type or namespace definition, or end of file expected. Does anyone know a fix please?
Assets\Scripts\PlayerInteract.cs(11,12): error CS0246: The type or namespace name 'InputManager' could not be found (are you missing a using directive or an assembly reference?)
If the canvas is in your way in the scene and you keep clicking on it, just click the eyeball next to canvas in your hierarchy
i had a problem at 13:40 with PlayerUI giving the error message of 'Object Reference Not Set to an Instance of an Object'. If any of you have this problem, make sure you set the playerUI public, do not set the component but pass the component with the PlayerUI to it.
Thanks for the tutorial though!
Need MORE!
terrific job Natty Gamedev!
LEGEND
im trying to make more interactables. when i go close to the new ones, it doesnt come up with any text. but when i go to the keypad, it shows the keypad text on all of them. please how do i make this. im doing a project with lots of interactables
thank you
when I interact with the keypad, it's giving an error :
Object reference not set to an instance of an object
In Keypad, line no. 25
Hey, Awesome tutorial but I have a problem at 18:40 my animation didn't get smooth. I tried making another keyframe but then my animation got stuck from switching to open and closed state. When I didn't try to smooth my animations they were normal, but when i add another keyframe everything brokes.
me too
If you mean that it's closing rapidly, then you need the third animation clip.
Its firs keyframe should contain transform values from the opened animation and the second keyframe - from closed.
Then put it on the transition from opened to closed.
Hope that helps :)
Great tutorial but unfortunately I am stuck on 15:58, because there's a error popping up saying that "'InputManager' does not contain a definition for 'OnFoot' and no accessible extension method 'OnFoot' accepting a first argument of type 'InputManager' could be found (are you missing a using directive or an assembly reference?)". I'm completely new with Unity so please can you help me on how to solve this problem?
So I believe you will need to change the private Onfoot variable to public (in input manager). And make sure the names match in both scripts...
@@NattyGameDev Thank you so much I don't think I would of ever figured that out everything works now how it should👍
@@NattyGameDev i still have problems
with this part :(
Assets/Scripts/Player/PlayerInteract.cs(36,34): error CS1061: 'InputManager' does not contain a definition for 'OnFoot' and no accessible extension method 'OnFoot' accepting a first argument of type 'InputManager' could be found (are you missing a using directive or an assembly reference?)
@@EmberGlide i found that after like the second time making the o inputManager.OnFoot lowercase instead worked as inputManager.onFoot
i have this problem Assets\scripts\PlayerInteract.cs(28,38): error CS0118: 'hitInfo' is a variable but is used like a type
hey i need help at around 7 minutes into the vid, it says interactable does not have a definition for promptMessage or smthn
were the video for the door an keypad i didn't see it in the first video an i can't get into your discord to try to find it just need some direction?
@Natty GameDev hi, i did the opening door thing, but i dont have to press the e key instead if u just look at it it opens and closes over and over again, do you know how to fix this?
i was having issues with the text prompt popping up when my raycast lines up with my button but i have no errors the code is fine and i have the scripts connected to the right objects so what do i do?
there is a way to stop the ray crossing throw walls?, i dont want to interact with the keybord form the other side of the wall
Very good work!! I just started programming in Unity and it already seems super-powerfull! And a little problem: It started appearing a little joystick at the bottom of the screen. Should it be there?
If you did the first episode, we have to do xbox ios controls, if I remember, maybe its that/
@@user-gl7gj5mq2n no, i just found out is a gizmo but thanks anyway
hey
so i want to make a first person cooking game and i want to move objects like in portal
how do i do that
yo man great vids learning alot your honestly great big up my man for that. but im have trouble finding out how to centre the camera when the game starts i currently always start looking at the floor. also i have a big box in the scene saying "new text" when i click on "canvas" it highlights it, any suggestions? @Natty Creations
um i have an issue inside this if statement if(inputManager.onFoot.Interact.triggered)
it is detecting the input but when it calls the base interact function the debug.log doesn't work
I dont know to fix this pls help
I'm getting the error " "InputManager" does not contain a definition for "OnFoot" and no accessible extension method "OnFoot" accepting a first arguement of type "InputManager" could be found" is there any way I can fix this?
Edit: Nevermind, I LEGIT JUST HAD TO CHANGE "on" to "On". 🤦♂️🤦♂️🤦♂️🤦♂️
is there a part in this video where you show us how to make the walls, keypad and cake stand?
they're just made out of cubes
🍌
🍅
also, when you clicked on the keypad, you changed the prompt message on the right. could you tell me why i didnt have that?
I have a problem where the interact key is double clicking without being pressed more than once. Any ideas how to fix?
Uhh i think this is an error prior to the previous one but i cant test out the game as the error says :
the variable cam is not assigned(player look)
please i want quick help
great vid, around 17 minutes in, I get an error
Assets\Scripts\Player\PlayerInteract.cs(36,33): error CS1061: 'InputManager' does not contain a definition for 'OnFoot' and no accessible extension method 'OnFoot' accepting a first argument of type 'InputManager' could be found (are you missing a using directive or an assembly reference?)
idk how to fix this, please help me
i believe he addressed that in the comments
I FOUND THE SOLUTION ON THIS:
Assets\Scripts\Player\PlayerInteract.cs(36,34): error CS1061: 'InputManager' does not contain a definition for 'OnFoot' and no accessible extension method 'OnFoot' accepting a first argument of type 'InputManager' could be found (are you missing a using directive or an assembly reference?)
In the PlayerInteract script the 36th line you have to change OnFoot --> onFoot. It is wrong in the video , dont use capital letter. Just simple onFoot. The right line is: " if (inputManager.onFoot.Interact.triggered) "
how do you get all those suggestions for what to put in ? please help i think it would make it alot easier to follow the tutorial and not have to pause all the time, Thanks !
16:54
Is it just me or did the lines
private GameObject door;
private bool doorOpen;
and
doorOpen = !doorOpen;
door.GetComponent().SetBool("IsOpen", doorOpen);
come from nowhere
no it did
Hey guys everything was fine until I entered this line of code @6:15
if (Physics.Raycast(ray, out hitInfo, distance, mask))
for some reason there's a red squiggle at the end of it (25,59)
any ideas I'm dead sure I entered it correctly thanks in advance
im getting an error which says "Assets\Scripts\Player\PlayerInteract.cs(36,34): error CS1061: 'InputManager' does not contain a definition for 'OnFoot' and no accessible extension method 'OnFoot' accepting a first argument of type 'InputManager' could be found (are you missing a using directive or an assembly reference?)" it happens when i try to interact with the keypad at 17:02
I FOUND THE SOLUTION ON THIS:
Assets\Scripts\Player\PlayerInteract.cs(36,34): error CS1061: 'InputManager' does not contain a definition for 'OnFoot' and no accessible extension method 'OnFoot' accepting a first argument of type 'InputManager' could be found (are you missing a using directive or an assembly reference?)
In the PlayerInteract script the 36th line you have to change OnFoot --> onFoot. It is wrong in the video , dont use capital letter. Just simple onFoot. The right line is: " if (inputManager.onFoot.Interact.triggered) "
@@peterfarago7727 yeah i found out about it in the discord server that the creator has
I am at 9:25 and i don't get any errors and did everything but when i go to the door it doesn't appear in console. One thing that i have to say i put the keypad to be the door cause i am trying to press on the door and open it. The door layer has interactable
im in 2024, this still works great!
When this game is exported, will it continue to use the "look with mouse" system as shown or will it be a similar system as to most first person games? I just find the system somewhat obnoxious.
Assets\Scripts\Player\Playerinteract.cs(34,33): error CS1061: 'InputManager' does not contain a definition for 'OnFoot' and no accessible extension method 'OnFoot' accepting a first argument of type 'InputManager' could be found (are you missing a using directive or an assembly reference?)
I have the same error
it should be "onFoot", but then you get this error message:
PlayerInteract.cs(36,33): error CS0122: 'InputManager.onFoot' is inaccessible due to its protection level
@@vasyuey i tried that already
@@command_crafter1004 i figured it out. It works now for me. Send me the error you get now, and i will tell you how to fix it
I FOUND THE SOLUTION ON THIS:
Assets\Scripts\Player\PlayerInteract.cs(36,34): error CS1061: 'InputManager' does not contain a definition for 'OnFoot' and no accessible extension method 'OnFoot' accepting a first argument of type 'InputManager' could be found (are you missing a using directive or an assembly reference?)
In the PlayerInteract script the 36th line you have to change OnFoot --> onFoot. It is wrong in the video , dont use capital letter. Just simple onFoot. The right line is: " if (inputManager.onFoot.Interact.triggered) "
hey @Natty GameDev when I walk The white ray that interacts with things does no follow me how can i fix
i would ask you on discord but the invite is invalid and thank you ;)
I have an error where during the final part of making the door open I can't open the door because it says "The variable door of Keypad has not been assigned" but I followed everything in the video and tried to tweak things but the door still won't open.
Çok teşekkürler
I mean thank you
Thanks for the totorial! But I keep getting the message that playerUI is inaccessible due to its protections, setting it to public didn't help, please advice!
make it public
where am i supposed to plug that code into from the end of the video?
how do i make the doors a different colour then the walls? and how do i make the switch?
I have a error and it says that error CS0117: 'PlayerUI' does not contain a definition for 'UpdateText'
I don't know how to fix this error. "Assets\Scripts\PlayerInteract.cs(29,74): error CS1061: 'Interactable' does not contain a definition for 'promptMessage' and no accessible extension method 'promptMessage' accepting a first argument of type 'Interactable' could be found (are you missing a using directive or an assembly reference?)"
i don't know why but after adding the animations and finishing the keypad script, when i try playing, it doesn't work when i interact with the keypad, i press E but nothing happens, it doesn't say anything about it in the console either
7:40 “The type or namespace name 'Interactable' could not be found” does this have to do with me having to put the Interactable layer on layer 8?
Really appreciate the video as its exactly what I needed for something I am doing for a school project, but I am getting an error in the "Player Interact" script. It says the "InputManager" could not be found. I did stuff fairly similar as instructed throughout the video, but I cannot seem to fix it. Any help from anyone would be appreciated!
[Here's exactly what Unity said: Assets\Assets\Scripts\Player\PlayerInteract.cs(13,13): error CS0246: The type or namespace name 'InputManager' could not be found (are you missing a using directive or an assembly reference?)]
Jump on the discord and post a screenshot of the code and we should be able to figure it out :)
Were you able to find out because I’m having the same problem
@@r0gue278 Natty helped. We were able to get it to work, but it wasn’t accepting inputs near the end and I just took a break. Just join the discord and ask for help and explain your problem in the “coding help” channel. A lot of people in the server are very helpful.
@@thebizarian I found out that I had to put onFoot instead of OnFoot in the raycast
@@r0gue278 Ah, yep. Casing definitely sucks
Hello , can you please explain how did you create the doors and other objects....It's my first 3D game and I don't know how to create those objects without any tutorials