#2.5 Interaction Events! :Let's Make a First Person Game in Unity!
HTML-код
- Опубликовано: 22 май 2024
- In this video We're going to expand our interaction system to include the use of Events!
This is a really powerful way for us to quickly prototype and design our interactions!
Health Bar Tutorial
• How to make a Better H...
00:00 Introduction
00:30 Unity Events Example
01:15 Interaction Event Script
01:53 Interactable Extras #1
02:25 Interactable Editor Script
06:11 Interactable Extras #2
07:07 Showtime #1
08:02 Event Only Interactable
10:20 Showtime #2 - Игры
I just wanted to say that i appreciate that your not only speaking clearly and making it obvious what were supposed to do which makes this tutorial 100% easier for everybody but also that the things that you are teaching us are not for only 1 game or 1 function in specific but the fact that the things your showing in these videos are covering IMPORTANT and REQUIRED parts of unitys engine and functions is so nice to me. the people including me that watched this video can take this knowledge and create something completly different than just a fps. rather something like a driving or a escape game. Keep up the good work loving this seris
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
These two video about the Interactions have been one of the most insightful and useful tutorials I have ever watched.
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
omg someone who shows a good script
i mean there are plenty of good scripts out there on youtube but
this guy explains all the important parts imo and shows decently advanced use cases like using events and inheriting from other classes etc this was just great!
earned your self a sub buddy thank you
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
Super helpful. I’ve been writing code for a few years but I’ve never used game making software before. Unity is a bit intimidating for me but I figured I may as well dive in. Glad there’s people like you out here making helpful tutorials :)
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall did not already know that come to Christ repent non denominational
You are a great teacher. :)
When I make it big, it is important that I send fans to your channel.
"Natty Creations can help make you big too!"
I think your viewers are all learning a lot. So we will all make something awesome.
Stay excellent and rock on!
This opened up so much potenial for my game... holy moly... thank you so much for this!
Amazing tutorial. Got stuck a few times, but i fixed it! Your channel has huge potential. Your commentary is to the point and calming. Its amazing to know how much can be achieved by UnityEvents. You are the only youtuber I can find that makes an up-to-date tutorial on first person shooters in Unity. The quality of your videos are really beautiful. Cant wait for part 3!
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
These are pretty high quality tutorials. Definitely have the potential to be one of the largest game dev channels on yt. Thanks btw
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
@@user-tu7ug2kx7tPOV: most random comment 🤣
Hi, I really appreciated this tutorial (I subbed of course) but I would like to say thanks for your help. I've been starting JS code at the moment, and C# is entirely new to me, so this tutorial is a massive help to me, as I've aquired a decent amount of knowledge on C# now. So you should 100% keep doing what you're doing, as now I am learning how to develop my own games :) This is so much easier than the other bad tutorials that take ages and you don't learn anything! Finally, when you showed what each segment of the code and what it meant, it helps a lot, as it has now given me a decent amount of knowledge on C#. Thank you, I can't wait to try to publish this game once it's complete!
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall did not already know that come to Christ repent non denominational
This video is very well made and exactly what I was looking for, I have been trying to make a first person shooter for a long time and was extremely happy to come across this! keep up the good work :D
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
Great video! Can't wait for new tutorials from you :D
This is what we need! Need moooore!! Thank you!
Great video. Looking forward to the next.
I have learned so much in these last three courses than taking 2 Udemy courses combined. Thank you!
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
Thank you, this is so helpful!
your videos are so amazing!
Why i didn't see that before? It's so helpful. Thank you
Great Tutorial
Thank you
Make more tutorials please
this will be very helpful for us keep going legend
This was really good! Thx alot for this! 5 star!
Can't wait for the next one!
Best unity tutorials i ever seen. Would be nice to see more episodes.
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
Thanks for making this, I would like to note the irony of "Let's show you a scriptless thing" and in the next minute "This will be the second easiers script you'll write" I do appreciate what you've done and it's helping me grow greatly as an individual
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
Awesome tutorial, please make the next videos...
Super late to this tutorial, but *thank you* so much for making this tutorial. You go fast, which helps for keeping ideas fresh and linked together, but you speak plainly and clearly so it's really easy to scrub back through the video if I missed a small step.
I tried so many times to get into Unity, but using Unity's own tutorials is a slog and they spend forever going over basics that really only need 2 seconds if you've done any kind of programming before.
My only suggestion: add one of those overlays that shows what key combinations you're pressing so that if you use some shortcut it's visible :)
amazing video cant wait for more
Liked and subscribed!
I love your teach thanks!
great work💯🤛
Nice tutorial
Wow. it is very helpfil video!
Yay the next one!
Thank you Natty!
Amazing tutorial, when is the next one coming?
Thank you so much!
Thankyou so much 💜
THANK YOU!
ur so cool🔥🔥🔥🔥thanks so much!!!
Thanks!
Thxx so helpfull
Legend bruh
Great point, I am creating a simple coffee game where we take "coffee" to our hand and place somewhere else that is interactable. For example, we put it to coffee machine, in this case Coffee Machine is also interactable, but it needs a coffee to interact, in this case what would be your solution? Should it just check for if the player has cofee"? Because its 2 kind of interaction, one is "no requirements" and the other ones are required smth. Like a trash can. Trash can should work only if our hand is not empty
please bring next part!!!!!!!:)
*HINT*: If you don't see prompt for the new cube, make sure to set its layer to "Interactable". It's required by the code from previous videos
Man I can't wait weeks for new episodes would be nicer if you could upload more frequently
hello there I am learning game development from your this game series , can you complete this series asap, btw love your video
first off, I'd just like to say that the tutorial was realy helpfull, however I have run into some dificulties, for starters, in the InteractibleEditor script, Unity is telling me that else cannot be used to start a statement, what do I do?
I have one problem. I dont have the help box message "event only interact can only use unity events" I looked back and did everything the same as you. There were no errors or anything, it just isnt there. Everything otherwise works
Awesome tutorials, as all parts before 🙂
Little question: Is there a way to create prefab doors with this system? Actually i have to create new animations for each door 😞
prefabs should store all the animations
Cool
when is the next tutorial I liked allot the 3 videos I learned allot
Hi! wanted to say that I really love this series, but I encountered a little issue and im not sure why or how to fix it.
So essentially, I implemented everything as it was shown in this video, and it worked like a charm, except for prefab objects. The interaction system, for some reason, just refuses to work on prefab objects. I tried applying the two scripts to the prefab AND also to the singular object in the scene, and neither one worked and im not at all sure why.
Question: When pressing the button, is there a way to revert the color back to its original color when you close the door using the Interaction Events?
Hey Even I am looking for this answer, Please let me know If you found something T_T
Use a Boolean to determine what you want to happen.. Then in the interact method. Just toggle the Boolean.. it's basically the same logic that is covered in the video
Hey mate, quick question. You mentioned that with this method we can do "basic" interactions. Does this also cover the animation interaction we did last episode, or do we still need to make new scripts for every time we want an animation or something a bit more complex than a material swap to happen?
So we are limited to methods that only use 0 or 1 parameter when using the Unity Event system..and unfortunately there is not SetBool method that takes 1 parameter.. You could use SetTrigger for a similar effect (however i'm not a fan of using triggers in the animator)
I did spend a number of hours trying to prototype a way to do the same thing with the Event System,
but I was not able to figure it out.. You need the 2 parameters for a lot of the animator methods.. SetBool, SetFloat, SetInteger.. this is because we need the "name" and "value"..
Using SetTrigger will just require a string for the "name" of the animator state..
Hope this helps!!
@@NattyGameDev i know this is like 11 months late but the way i got the door to open and close using the interaction event was to have a script called door that has an empty void like this:
protected override void Interact()
{
}
then i ticked the use events checkbox and called a door toggle method on interact. this was the door toggle method:
public void DoorToggle()
{
if(door.GetComponent().GetBool("IsOpen") == false)
{
door.GetComponent().SetBool("IsOpen", true);
}
else
{
door.GetComponent().SetBool("IsOpen", false);
}
}
Its not a perfect work around but it works for me
@@inept6986 you can simplify this by just doing
public void DoorToggle()
{
door.GetComponent().SetBool("IsOpen", !door.GetComponent().GetBool("IsOpen"));
}
I got a problem with the Input,using the PlayerInput I cant set the startmenu click event.
InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
I really dont know how to sovle it or use PlayerInput in startMenu
For example i want to make a prompt message to open a door when door is closed and close the door when the door is open, How can i make two prompt messages.
Hey when I try to attach the EventOnlyInteractable (Script) to my cube, Interaction Event (Script) won't show up. Any solutions?
Meetoooo! Keypad and InteractionEvent do no seem to get along, I can attach one or the other but not both. Recreaded, same deal. Use an emply gameobject and it will not take both scripts.
I'm running into a problem after 5:00 in the video, it gives me the error, "The type or namespace name 'InteractionEvent' could not be found (are you missing a using directive or an assembly reference?)
check your InteractionEvent.cs i forgot how i solved it but i remember i checked the script and said "ooohhh how did i miss that". and one more thing check inheritance
i remember now the if you changed the name after creating the script it doesnt changes name in script make it
"public class InteractionEvent : MonoBehaviour"
not
"public class NewBehaviour... : MonoBehaviour"
that was my problem
@@misterr2293 It is 1 am for me right now but I'll check it out in the morning. Thank you so much!
i need help it only shows the interaction event when use events is unchecked
I done all the scripts and checked it multiple times but I am still getting A lot of the interaction event on my inspector. does anyone know how to solve it.
When saving the game, why doesn't the interaction event save its event???
I followed along for the Editor script and I get zero errors but when I click Use Events nothing happens PLZ HELP
I think I'm understanding what you're teaching, but at the same time, I'm very confused. I mean, I get what you're saying, but I know I can't rewrite these scripts and redo those things by myself later. Because I don't understand a lot of the scripts, like why you're choosing certain words, why you're using < or ( or [ or { in certain places, or why you're writing those words exactly here. That's why I think I won't be able to write those codes by myself. When I watch any tutorial videos, everyone says 'Thank you, now I get it, now I understand.' It seems like I'm the only one left with confusion. Should i just memorize those methods and classes and other scripting words ? Or i need to understand logic behind it and i will be able write anything ?
Am I really that dumb, or does everyone have the same situation? 😥
@Natty, how is the
public virtual string OnLook()
used? It is there at the start of this video but not on the end of the previous one?
in the interactable script use UnityEditor;
@@tezdiem huh?
huh?
@@tezdiem
doesnt seem to work and I checked over everything multiple times the event only interactable
Thank you for this great tutorial. I am stuck at one point where an interactive component is added.
calling interactable.gameObject.Addcomponent() gives the error that InteractionEvent is not of the type UnityEngine.Component. I have defined InteractionEvent exactly as mentioned in tutorial. Can you help me here.
Is that copy pasted from your script??? If so you may need a capital letter on C in AddComponent
@@NattyGameDev same thing happened to me :(
Hey i would need some help. Everything was coded correctly and i get no errors, but when i try to interact with the cube nothing happens it shows the text "designed using events" but nothing happens. I also have a problem with the keypad, i can interact with it but it doesnt change the material like in your video it only opens the doors for me. i hope you see this and can help
I’ve been having the same problem
i just came back to this and all i did was i completed the whole video and then checked back if everything worked and now it works@@Jaidam_
for some reason at 7:21 I do not have mesh renderer as an option?
Did you figure it out?
New part any soon??
its a good day when you see a natty video in your recommended
Amazing tutorial!! but i have some problems... when i check the Use Events nothing happens and i get an error sayng that the is a "," in the wrong place???????
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall did not already know that come to Christ repent non denominational
I know this is a very late comment however when i click "use events" under keypad it does not give me and interaction event script. i have double and tripple checked my code and i dont know what the issue could be.
Edit : i do not know what caused it however i went back and rewrote everything and it now works....
I'm also having that issue
Nvm I fixed it, one of the it atocorrected to
Does anyone else’s unity crash when adding scripts to the player or am I doing something wrong
great video, but i have an error i need help with,
"Assets\Editor\InteractableEditor.cs(11,43): error CS0246: The type or namespace name 'InteractionEvent' could not be found (are you missing a using directive or an assembly reference?)"
what do i do now?
Never mind, i got it.
@@ziginator7689 How did you fix it?
@@Fling569 i had interaction misspelled for the interactionevent script after i fixed that it worked for me
same error, i mispelled the name at the top of the interactionevent script
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
very good tutorials but maybe slow down a bit i need to pause frequently to get all the code in
i cant find the glow material
I have tried doing this with the keypad script, but it just won't activate it at all. I tried with the button with baseinteract, but it just does nothing when I click it. Any solutions?
I forgot to say that the keypad still functions normally and it plays the door animation when I click the keypad, but for some reason unity events just does nothing
Hey, I'm having the same problem. Did you manage to fix this by any chance?
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
where did he get that cross hair
Hey, thank you so much for the video. For some reason I can't get this to work... I try to interact but nothing happens, no error, nothing. Any idea how to fix this?
It would be so helpful if you could put the project scripts on Git!
Thanks again for the tutorial!
So, guess what? After a couple of hours of going mad, it turns out the problem was bad indentation in OnInspectorGUI() :') can confirm this works perfectly fine in Unity v. 2021.3.17
not sure if you still need this but this happened to me and i realized that I forgot to set the interactable object's layer to "Interactable" (like we did in the last video)
How did you create the crosshair?
he did it in the second tutorial i believe
I feel like i have to repay this guy lol
Hello everyone, I have a question, how can I customize the key that has to be pressed to interact, so that with different interactions I can press other keys?
You would have to add more actions in the input manager object, i would start with duplicating the interact action that we have now. after that, simply change the key and it should work
@@awiseauthor3456 no actually I want to have more interactions in the same scene, which each have a different key to be pressed
At 4:16 the top bit of the script disappears.
I get the prompt message but when I interact with the cube it doesn’t do anythinf
ik im a bit late, but if you have multiple events, make sure to fill ALL of them or else it wont work
WE NEED TO LEARN HOW TO USE GUNS!!!!!!!!
hi i am stuck at 6:26 because when i put the GetComponent().OnInteract.Invoke(); invoke doesnt get recognize can you please help me fix it?
Hey mate. Did you add in maybe InteractableEditor or another script with almost the same name? if not, did you remember to add the "public UnityEvent onInteract;" inside of InteractionEvent?
@@emp3950 This fixed it for me, I had "UnityEvenQueue" or something like that
@@Papa_Tin glad to hear it. good luck with your game man
I have problem, 5:47 we write DstroyImediate but it said that the name 'DestroyImediate' does not exist in the current context? that someone have a solution?
Finally im good i missing a M
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall did not already know that come to Christ repent non denominational
ehh invoke is not working
I'm getting the error CS0246 in InteractableEditor.cs saying that name/namespace EventOnlyInteractable in line 9 cannot be found. Im sure its a simple fix & Im just missing it. Can anyone help?
I had the same issue and found the fix. Did you make the EventOnlyInteractable C# script from 8:20? If so, did you spell it right since it is case sensitive?
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominationalNot sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
Has anyone tried to animate a button? I tried using the door code and was hoping someone knew how to make it a temporary animation that happened once and turned off, rather than being a loop or locking in place. Any suggestions much appreciated.
Have you checked the second episode?
@@user-gl7gj5mq2n I think I just didn't understand why it wasn't working for me
@@K_J_Coleman_Composer Its in the link in bio second episode
i did i just ocoppied the code and made a seperate one for the key pad, then added the animation as shown with the door, and aplied it to the button
waiting for ur new video
Next video will be coming soon!
Assets\Editor\InteractableEditor.cs(21,32): error CS1061: 'Interactable' does not contain a definition for 'GetComponent' and no accessible extension method 'GetComponent' accepting a first argument of type 'Interactable' could be found (are you missing a using directive or an assembly reference?)
PLSS HELPPP
If you're still struggling with this, go into your InteractableEditor scipt and paste here the part underlined in red so I can see the line of code
did you fix this?
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall did not already know that come to Christ repent non denominational
@@whomp3817 DestroyImmediate(interactable.GetComponent());
Why do we see useful stuff like weapon pick ups in the thumbnails and end up doing basic stuff like painting doors?
That's because I’m trying to free your mind, roman. But I can only show you the door. You’re the one that has to walk through it.
@@NattyGameDev 🙌
@@NattyGameDev I appreciate that. Its the right way. But changing colors on a door and understanding object kinematics are two different things. Your're thumbnails are missleading about the content, just for more clicks. If you show people how to change color on doors than you should use colored doors in your thumbnail.
How to make a sprint key
That’s at the end of the first episode
just waiting for more amazing content
This is starting to look like a first person shooter without shooting lol
Yeah because its not like you add guns right away. You need to add movement, interactions, and enemy ai mother
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
This type of controller doesn't work the way you display in your video. Are you using a different code than you showed us? If you click the button, you WILL be looking at the floor. No way around that the way the code is written.
Hello Unity says that the useEvents does not contins a definitions for useEVents.
Assets\Editor\InteractableEditor.cs(11,26): error CS1061: 'Interactable' does not contain a definition for 'useEvents' and no accessible extension method 'useEvents' accepting a first argument of type 'Interactable' could be found (are you missing a using directive or an assembly reference?)
And Another Error
Assets\Editor\InteractableEditor.cs(13,17): error CS0120: An object reference is required for the non-static field, method, or property 'Component.GetComponent()'
you have written Component twice should be like this "interactable.GetComponent() "
and useEVents should be useEvents with a small V
did you fix the first error? i have the same problem
Not sure what yall believe in not trying to force my believes on yall just wanted yall to know Jesus loves yall if yall didint already know that come to Christ repent non denominational
I am attempting to add the Interaction Event to a Prefab and when I uncheck Use Events the Interaction Event does not get erased. Additionally I get the error "Destroying assets is not permitted to avoid data loss.
If you really want to remove an asset use DestroyImmediate (theObject, true);
UnityEngine.Object:DestroyImmediate (UnityEngine.Object)
InteractableEditor:OnInspectorGUI () (at Assets/Editor/InteractableEditor.cs:21)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
"
I went ahead and changed it to that function call and it now removes the event.