How to Add Interaction in Godot 4

  Рет қаралды 15,770

Nagi

Nagi

Күн бұрын

Пікірлер: 119
@mrjshzk
@mrjshzk 4 ай бұрын
I've been watching Godot tutorials for a while but this one is very interesting! I never thought about using an animation tree for a door!
@malplex
@malplex 2 ай бұрын
Just want to say that your tutorials are great, they helped me a lot to learn Godot, thank you
@Keallan
@Keallan 29 күн бұрын
bro TYSM for these tutorials! i never found any tutorials that are as interesting as yours tbh
@NekotoArts
@NekotoArts 4 ай бұрын
The King returns! Also really great resource! Some of this stuff they updated in Godot 4 confused me haha, but it made sense after watching the video.
@amegatron07
@amegatron07 3 ай бұрын
Thanks for the video) Was going to make exactly such interactions, except that I was planning to have multiple "features" of objects, one of which would be "Interactable".
@grzegorzpedrycz2630
@grzegorzpedrycz2630 4 ай бұрын
Awasome piece of knowlage !
@superandreluizduarte
@superandreluizduarte Ай бұрын
A tutorial video that doesn't FEEL like a tutorial is my thing, great video!
@amirosman8797
@amirosman8797 4 ай бұрын
This is amazing, great video man and welcome back, I hope you are planning on making more tutorials
@DuhKoreGames
@DuhKoreGames 2 ай бұрын
lol just found your channel like 2-3 days ago and was translating all the interaction stuff from godot 3 video to my 4.2 version XD could of just clicked on your channel to find this updated one smh either way im gonna watch it!
@mannythepirate
@mannythepirate 3 ай бұрын
Hey Nagi! I like your videos. Keep it up!
@vishnuviswanathan4763
@vishnuviswanathan4763 4 ай бұрын
welcome back dude
@clashofclans9783
@clashofclans9783 4 ай бұрын
Nagi when the player collides with a physical object, the physical object penetrates the wall or the ground. How can I fix this?
@NagiDev
@NagiDev 4 ай бұрын
CharacterBody vs RigidBody collisions tend to be that way. I haven't found an all-in-one fix for it, but depending on your game, you can make both the player and the object be either both rigidbodies or both characterbodies. You can also try the Jolt physics plugin but I'm not sure if it'll fix the issue.
@clashofclans9783
@clashofclans9783 4 ай бұрын
@@NagiDev jolt physics didn't fix anything the last solution make player and the object with rigidbody Thx Nagi😊🙏🏿♥️
@bartimusprimed
@bartimusprimed 4 ай бұрын
Your videos are great, keep up the good work!
@ruumroom.
@ruumroom. 4 ай бұрын
amazing video mr nagi keep em coming
@yc5882
@yc5882 2 ай бұрын
I have a quick question: If I wanted to make it so that you had to hold down an action key for a certain amount of time and have a progress bar on the screen that shows how far along the interaction is, how would I go about that?
@DuhKoreGames
@DuhKoreGames 2 ай бұрын
do you know how to implement a mouse click into this? ive tried to do replace E with LMB or RMB and it shows up invisible
@Thewallrunner749
@Thewallrunner749 2 ай бұрын
Could you make a tutorial for a pick up and drop system similar to granny ?
@Meraba_Abi
@Meraba_Abi 3 ай бұрын
Amazing work. Keep it up.
@KelpDev
@KelpDev 2 ай бұрын
hey bro, can you make a graph edit and graph node tutorial, because I have an idea to make a game engine with godot with visual script as the script component.
@jamesrivettcarnac
@jamesrivettcarnac 3 ай бұрын
This is really well done
@nettorb_
@nettorb_ 4 ай бұрын
Very nice video, the animations a pretty cool :D Btw, when you set in the code to show what button to press, how can I make it show the mouse buttons like LMB or RMB? The code shows any other button, but the mouse ones it onlu shows "[]" This is the code i'm referring to: action.as_text_physical_keycode()
@NagiDev
@NagiDev 4 ай бұрын
Heyo! So sorry for the late reply, but I found the solution! You should update the code in Interactable.gd like so: if action is InputEventKey: key_name = action.as_text_physical_keycode() break elif action is InputEventMouseButton: key_name = action.as_text() Hope this helps! Also, I'll push this code to the github repo. Thanks for the question!
@nettorb_
@nettorb_ 4 ай бұрын
@@NagiDev No problem, thank you so much! that really helps! :D
@Float212
@Float212 4 ай бұрын
Duuuude where have you beeen?! Great video, also, can you do a video about enemy movement and animation? If you do I'll subscribe :)
@NagiDev
@NagiDev 4 ай бұрын
deal
@mimadm4832
@mimadm4832 2 ай бұрын
My game immediately crashes whenever I lok at any non-interactable object once I input the code from 7:23, the replacement of interact with collider.prompt_input. I got no clue on ohow to fix this, pls help also, the game just crashes whenever I press on any surface that isnt interactable
@NagiDev
@NagiDev 2 ай бұрын
can you share the error Godot shows on crashing?
@mimadm4832
@mimadm4832 2 ай бұрын
I have just decided to copy and paste your code to not bother with the headache, thabk you for the video and everything tho, once I open my pc I will tell the error message
@BreezyDefrag
@BreezyDefrag 4 ай бұрын
Ok, so I am not a code guru or anything so I more just want to ask a question. Couldn't you just use an Enumerator Variable and then just add the code together? Is there a better reason why you use a Custom Class, rather than an Enumerator? And could someone explain what case states would be good for Custom Class VS. Enumerator?
@NagiDev
@NagiDev 4 ай бұрын
To be frank, I'm not that bright myself, so maybe your approach would work just as well, if not better. Can you tell me more about the Enumerator approach a bit?
@BreezyDefrag
@BreezyDefrag 4 ай бұрын
@@NagiDev Well with an Enumerator, and I am only touching surface level stuff here as I am still new to coding, but as I understand it you could create an Export Enumerator String Variable with a list of object names then use a Match script in it's own function that will automatically set variables, Names, and Interact buttons, etc. under each match case. Example match string (string Var): "String name": set variables to values. Then you just put that script onto an interactable object which will then show a dropdown in the Inspector. And when you change that Enum String to whatever the object is whether it's a "Button", "Switch", "Key", etc. and each can have it's own functions, calls, and variable sets. under each match state, so you could make the key update a key count var elsewhere, or use the toggle system. This is just a rough breakdown of how I would do this. That's in part why I am asking for some case states for why you would use a custom class over an enum. Hope that makes sense. ^^ Great video though.
@NagiDev
@NagiDev 4 ай бұрын
@@BreezyDefrag well, that seems like an interesting way to handle it. However, from my past experiences (read, blunders) I try to steer away from putting all the code in one file. With the custom class, Interactable.gd can have all the code that would be common among all the interactive objects (prompt message, interaction logic, etc), while any logic specific to an interactive object can remain in its own script. Say, you want the button to play a press animation when interacted with. That code would only remain in the button's script. Hope you see my point of view. And yes, for a very basic use case, the enumerator method seems more easier to make, I'm just trying to make the system capable of being extended and customized.
@ChillySmalls2910
@ChillySmalls2910 16 күн бұрын
mine isnt showing the prompt message, it just says not then [E]
@NagiDev
@NagiDev 16 күн бұрын
can you please compare your vode with the one from the link in the description and see if you missed something?
@ChillySmalls2910
@ChillySmalls2910 16 күн бұрын
@@NagiDev i fixed it, thanks for the response though
@juanpablobarreto2414
@juanpablobarreto2414 27 күн бұрын
Everything was going well until the 04:31 label was not projected.
@NagiDev
@NagiDev 27 күн бұрын
Hi! can you please share in detail the issues you're facing?
@damnthishandleistaken
@damnthishandleistaken 24 күн бұрын
What if I want to open the door by directly interacting with it?
@NagiDev
@NagiDev 24 күн бұрын
I mentioned it in another reply, but basically you add an Area3D node to the door scene, add a CollisionShape to it, add the interactable script to the area, and finally connect the signals like in the video.
@damnthishandleistaken
@damnthishandleistaken 24 күн бұрын
@@NagiDev Oh, that seems pretty obvious haha I'm so dumb. Thank you so much for the quick reply!
@NagiDev
@NagiDev 24 күн бұрын
@damnthishandleistaken calling people dumb is not allowed (especially when that person is yourself). You're still learning, it's okay.
@JiKayPh
@JiKayPh 3 ай бұрын
Can you give me more videos explaining the buttons in detail in Godot?
@NagiDev
@NagiDev 3 ай бұрын
What parts would you like to know more about?
@JiKayPh
@JiKayPh 3 ай бұрын
@@NagiDev You can teach the necessary knowledge or use in a platform-style game
@NagiDev
@NagiDev 3 ай бұрын
I've shared all the necessary information about the button in this video. However, I can understand I didn't explain some of the Godot features thoroughly. You can watch my Godot 3 interaction video for some clarity or there's also plenty of videos on KZbin explaining Godot raycasts, area3D and signals (3 of the Godot features used in this video). But yeah, I plan on making much smaller videos in the future explaining these concepts for beginners. Cheers!
@JiKayPh
@JiKayPh 3 ай бұрын
@@NagiDev Thanks you so much ❤
@tigergamespl2713
@tigergamespl2713 Ай бұрын
for some reason my raycast doesn't detect like at all
@NagiDev
@NagiDev Ай бұрын
Enable debug collision shapes from the debug menu and check if the ray cast may be detecting the player body itself. Or maybe you've set the collision layer of the raycast/collision object to some other value?
@tigergamespl2713
@tigergamespl2713 Ай бұрын
my bad, i guess i have to make it a child node of the camera so it would go with my screen since i guess that's how I set up my code
@Thewanderer-ym9xs
@Thewanderer-ym9xs 3 ай бұрын
If I only wanted to add the crosshair to the UI part, do I have to add script to the control node?
@NagiDev
@NagiDev 3 ай бұрын
If you only want the basic crosshair, you don't really have to add any script.
@Thewanderer-ym9xs
@Thewanderer-ym9xs 3 ай бұрын
@@NagiDev thanks!
@joaovitorgutkoskipaes1850
@joaovitorgutkoskipaes1850 13 күн бұрын
"This is gonna be a long one" ... 16 min 😂😂
@NagiDev
@NagiDev 13 күн бұрын
It took me a long time to edit 😭😭
@quiet5445
@quiet5445 3 ай бұрын
bro i wanna say it still feels kinda with all of this much and stuff in scene can u please make a simplified vedio for this again just implementing these systems simple scene altho it seems really goodd for future proof but as a beginner its hard pleaseeeeeee make easy and simplified one 🥲🙏🙏🙏🙏
@NagiDev
@NagiDev 3 ай бұрын
Sure. Can you share which parts were hard to understand?
@quiet5445
@quiet5445 3 ай бұрын
@@NagiDev i wont say the whole vedio but for me the whole part for adding functinallity to button were difficult cuse according to me there was so much going on i could wrap my head around most of the things thats why i need a simplified verison and yeaaa overallllll great vedioooooo will ceratinly help me in future also can u make a simplified version for pickables stuff like torch will be gratefull for that 🥲🙏
@NagiDev
@NagiDev 3 ай бұрын
@quiet5445 ah got it. So the thing is, you can define custom signals in a script which shows up in the node tab (beside the inspector) when you have the node with that script selected. In this video I created a custom signal "interacted" and connected it through the node tab to various functions in other scripts. So for example, button (Interactable.gd) -> interacted signal -> do_something() (function) Basically when the interactRay interacts with an Interactable node, the node emits the interacted signal, this signal can be connected to any number of functions in any script. So, when the interacted signal is emitted by that node, all the connected functions are called, and we can put the code we want to run inside these functions like we did in the video. I hope this helps you understand what's going on in the interaction system. If you still have doubts, feel free to contact me over at Discord @nagidev. Also, I would suggest you to learn more about Godot signals since they are really powerful for all sorts of things.
@quiet5445
@quiet5445 3 ай бұрын
@@NagiDev thanku very much im just starting on this 3d project and your tutorial be of so much of help as there arent much tutorial on godot 4 on top of that you might not find what youre looking for altho interaction isnt that specific but still there isnt any vedio on youtube other than u that actually helped plus your the only one that replies tbh since getting replies from youtube channels nowdays is next to impossible until unless you comment on a recent vedio surely i would follow u on discord
@Papajoofable
@Papajoofable Ай бұрын
Hi bro, your videos are really cool, I can see how much you put into each of them. I would like to ask you about shapecast nodes, what get_collider index does ask for? I really need help😢
@asdfghjkl-jk6mu
@asdfghjkl-jk6mu 4 ай бұрын
did you create the assets yourself or got them from somewhere? they look so nice!
@NagiDev
@NagiDev 4 ай бұрын
Yeah, I made them myself for these tutorials. I'm glad you like it!
@_xome4ok_348
@_xome4ok_348 4 ай бұрын
Dude, your guides are great, keep up the good work, I'm looking forward to your videos about godot :)
@HappyCucco.
@HappyCucco. Ай бұрын
You made a causality dilemma because where do keys come from? And if you need a key to open a chest then where do you get the key to open a locked door? 🤯
@NagiDev
@NagiDev Ай бұрын
I did not sign up for this 😭
@nobisstudio8497
@nobisstudio8497 2 ай бұрын
Can show the blue border live player interacting with object
@NagiDev
@NagiDev 2 ай бұрын
Sorry, I don't understand the question
@strandedoutput2916
@strandedoutput2916 Ай бұрын
Only halfway through the video but I gotta say this tutorial is top notch my man. I was pulling my hair out trying to get this stuff working but you've clarified so many things for me.
@Insan_gaming01
@Insan_gaming01 2 ай бұрын
Thank you, friend, for explaining more about what I've been confused about all this time
@HakanBacon
@HakanBacon 2 ай бұрын
Well made video! Thank you
@BasicTechBoi123
@BasicTechBoi123 2 күн бұрын
help: Invalid access to property or key 'prompt_message' on a base object of type 'CSGBox3D'.
@NagiDev
@NagiDev 2 күн бұрын
Your raycast is detecting a CSGBox and trying to get the prompt_message property from it. Enable "show collision shapes" from the debug menu and check if the raycast is detecting another object in the way.
@NagiDev
@NagiDev Күн бұрын
Also, did you skip the condition check in the code? Please check if you skipped some part of the code as that may explain this error.
@alekjwrgnwekfgn
@alekjwrgnwekfgn 4 ай бұрын
Excellent content bro. Sub’d within a minute. Look forward to your upcoming videos; will catch-up with your catalogue.
@drawtheword7590
@drawtheword7590 2 ай бұрын
a little too fast for me i 'll just to watch it a few times. but seems really info
@MrGD49
@MrGD49 4 ай бұрын
You the GOAT no cap
@LilFishowo2.0
@LilFishowo2.0 Ай бұрын
5:58 i added the if collider is Interactable: line but now it wont show any prompt messages but it wont work without the line im on 4.2.2 is that why it no longer works?
@NagiDev
@NagiDev 29 күн бұрын
can you please check if you set the raycast to ignore its parent. Because in most cases, it turns out that the raycast is constantly detecting the player's collisionShape, hence no prompt message. This setting might be different for 4.2.2, I'm not sure.
@quiet5445
@quiet5445 3 ай бұрын
bro where are u are u dead ???
@dazarianwilliams4253
@dazarianwilliams4253 4 ай бұрын
Love your videos, I was worried you were gone after the long time since the last one great to see you're still at it
@thegamechallenger9120
@thegamechallenger9120 4 күн бұрын
Invalid access to property or key 'prompt_input' on a base object of type 'StaticBody3D'. Help please.
@NagiDev
@NagiDev 4 күн бұрын
this could mean either of these scenarios: - you haven't attached the script to the object - the raycast is detecting another object in the way - you skipped the condition checks in interactRay script - you probably misspelt the word somewhere Try to compare your code with the one in the description to see if you missed something?
@thegamechallenger9120
@thegamechallenger9120 2 күн бұрын
@@NagiDev Still, doesn't work. Thanks for the tutorial anyway.
@thegamechallenger9120
@thegamechallenger9120 2 күн бұрын
@@NagiDev Never mind the raycast detects another object. How can I prevent the raycast from colliding to another object?.
@NagiDev
@NagiDev 2 күн бұрын
You can put the object on a different collision layer and make it the raycast's mask to that layer. But I must warn you this way your raycast would be able to detect objects through walls.
@gwrgrw4077
@gwrgrw4077 3 ай бұрын
you should make a 3D dialogue tutorial pls
@NagiDev
@NagiDev 3 ай бұрын
Already working on that lol
@gwrgrw4077
@gwrgrw4077 3 ай бұрын
@@NagiDev thank you I love you nagidev i hope both sides of your pillow are cold tonight
@baraka74
@baraka74 Ай бұрын
Great tutorial, if someone can help me out tho, how would I make a door without a button? So u can just interact with the door itself.
@NagiDev
@NagiDev Ай бұрын
You add an Area3D node to the door scene, and add a CollisionShape to the Area3D. Then attach the interactable.gd script to the Area3D, connect the signals to the door script. Boom! Profit.
@baraka74
@baraka74 Ай бұрын
@@NagiDev Ty so much man!
@hallo2955
@hallo2955 3 ай бұрын
Thank you for your tutorial. The textures in your videos look amazing. Do you create them yourself? Could you please share your workflow? How do you create the normal maps?
@NagiDev
@NagiDev 3 ай бұрын
I'm glad you like them! Yes, I make them using Gimp and Krita. I hand paint all the textures and roughness map. For the normal maps, I draw the depth map (black is deep, white is shallow) and use the normal map filter in Krita to generate the final result.
@NagiDev
@NagiDev 3 ай бұрын
I should probably stream my workflow someday lol.
@queworldwow6262
@queworldwow6262 Ай бұрын
I have a question, what can make Raycast3D not rotate with parent object?
@NagiDev
@NagiDev Ай бұрын
If you don't want to rotate the raycast with the parent, you can set it as top level in the inspector, and then set it's position the same as the parent in the physics process function.
@queworldwow6262
@queworldwow6262 Ай бұрын
@@NagiDev thank you! I fixed it by myself yesterday, turns out my Raycast3D was actually working, it was just inside Area3D and aftwr moving it's origin a little bit away, everything got fixed
@alambogamer4204
@alambogamer4204 Ай бұрын
Is anyone else unable to find the "Interacted" signal?
@NagiDev
@NagiDev Ай бұрын
This could be due to a few reasons: - you might've forgotten to define it in the interactable.gd script - maybe you named the signal differently in the script - maybe the script if not attached to the node - maybe you haven't saved the script yet, so the signal is not showing up in the inspector Please let me know if I can help, I'd be happy to do so
@alambogamer4204
@alambogamer4204 Ай бұрын
Oh wow, I found the fix. I overlooked 8:04... Sorry about that. Thank you so much for your help tho! you are def unrated!
@Vstudios_Official
@Vstudios_Official 26 күн бұрын
I am getting an error - 'GameState' not defined. Where do i define it?
@NagiDev
@NagiDev 26 күн бұрын
Gamestate is an autoload we coded in the previous tutorial. You can either watch that or simply copy the code from the link in the description.
@Vstudios_Official
@Vstudios_Official 26 күн бұрын
Thankyou ​@@NagiDev
@LilFishowo
@LilFishowo 2 ай бұрын
So im getting an error after typing if collider is interactable: Prompt.text = collider.prompt_message Its rhe if statements thats not working its giving me a couldnt not parse global class error
@NagiDev
@NagiDev 2 ай бұрын
is the class name interactable (with a small i) or Interactable (with a capital I) in your interactable.gd script?
@LilFishowo
@LilFishowo 2 ай бұрын
@@NagiDev with a capital I for both
@NagiDev
@NagiDev 2 ай бұрын
Are you using capital i in your condition as well? If so, have you saved to interactable.gd script? Try to save and retry.
@LilFishowo
@LilFishowo 11 күн бұрын
@@NagiDev i did but now im having an error with running the game. it works sometimes and other times just refuse to work
@NagiDev
@NagiDev 11 күн бұрын
can you check your code against the code from the link in the description and see if you missed something?
@아프리카남서부마제스
@아프리카남서부마제스 3 ай бұрын
13:25 when make the gamestate?
@NagiDev
@NagiDev 3 ай бұрын
Yeah, we made the gamestate autoload in the previous tutorial.
@nan0core25
@nan0core25 2 ай бұрын
​ @NagiDev Hey, thanks for the awesome tutorial! Can you share the link of this tutorial? I'm stuck on this part too
@NagiDev
@NagiDev 2 ай бұрын
@nan0core25 Click on my name under the video to open my channel page, go to the videos tab, and you'll find the video "How to Code Player Health And Fall Damage in Godot 4" kzbin.info/www/bejne/jmfKl52ajciepqMsi=eWXttE4eFze7ZGxp
@renatorossarola
@renatorossarola 4 ай бұрын
I Made Minecraft in Godot
28:36
RachelfTech
Рет қаралды 50 М.
Optimizing my Game so it Runs on a Potato
19:02
Blargis
Рет қаралды 591 М.
Офицер, я всё объясню
01:00
История одного вокалиста
Рет қаралды 3,3 МЛН
The joker favorite#joker  #shorts
00:15
Untitled Joker
Рет қаралды 30 МЛН
🍉😋 #shorts
00:24
Денис Кукояка
Рет қаралды 3,4 МЛН
escape in roblox in real life
00:13
Kan Andrey
Рет қаралды 88 МЛН
Signals in Godot 4: Everything You Need to Know as Beginner
11:19
Lio Goes Indie
Рет қаралды 3,9 М.
6 Years of Learning Game Development
17:20
Cobra Code
Рет қаралды 137 М.
Godot Gridmap: ALL you need to master 3D Tilemaps
9:31
Revi
Рет қаралды 1,4 М.
I Made a Graphics Engine in Scratch
8:27
Zyger
Рет қаралды 139 М.
My Experience Moving to Godot from Unity
16:54
DarkDax
Рет қаралды 27 М.
Immersive Sim in Godot 4: COGITO - Overview
8:22
Philip D
Рет қаралды 41 М.
Modular Upgrades Made Easy Using the Strategy Pattern
6:41
Bitlytic
Рет қаралды 67 М.
Jiggle Physics in Godot
13:31
CoderNunk
Рет қаралды 82 М.
Mirrors, Every Way You Can Make Them In A Video Game
8:14
Code It All
Рет қаралды 65 М.
I made a Fighting Game Frame Data System for my Indie Game!
31:42
Inbound Shovel
Рет қаралды 24 М.
Офицер, я всё объясню
01:00
История одного вокалиста
Рет қаралды 3,3 МЛН