Тёмный

[Godot3] How to Click 3D Objects in Godot | Game Dev Tutorial 8 

Dave the Dev
Подписаться 4,7 тыс.
Просмотров 27 тыс.
50% 1

In this tutorial I'll demonstrate how to create clickable 3D objects in Godot. I'd love to hear from you, comment below. ^_^
Dave the Dev Tutorial's Github Repo: github.com/DaveDaDev/Godot-Tu...
RU-vid Music Library
Song: Nimbus
by Eveningland
/ @eveninglandmusic

Игры

Опубликовано:

 

1 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 54   
@Baekstrom
@Baekstrom 3 года назад
This is a much cleaner way of detecting a mouse click than the other method I googled that explained how to make a ray cast from the camera. Thanks!
@Crisisdarkness
@Crisisdarkness 4 года назад
Wow this is awesome, all the videos that you created are so useful, I'm sure your channel will have a large audience, thanks estimated Dave
@budigtoon418
@budigtoon418 4 года назад
I have seen some of your tutorials, and I think you have good knowledge and skills. I hope you are diligently uploading about the Godot 3D tutorial for the Godot community. thank you!
@OpsFox245
@OpsFox245 2 года назад
This is great just what I was looking for.
@Obsidian-Tux
@Obsidian-Tux 3 года назад
Thanks, this helped me a lot :)
@aleksandersanya1817
@aleksandersanya1817 2 года назад
Very helpful! Thanks.
@miguelsarmiento9268
@miguelsarmiento9268 4 года назад
click in 3d very good only you explain this thanks for the help
@hoppalapasam53
@hoppalapasam53 3 года назад
thank you so much, this is realy help me out. but i did use it with touch screen input touch. its work that way as well.
@anicepineapple9067
@anicepineapple9067 Год назад
Followed the video and nothing happened. Is this broken in 3.5
@joaofaleiro8297
@joaofaleiro8297 3 года назад
Thank you so much dude
@BenColemanUK
@BenColemanUK 2 года назад
This is fantastic, very simple, but it seems to allow me to click on objects which are hidden behind other objects in the scene, I don't know if I've missed a step but how do I stop hidden objects being clickable?
@biankro
@biankro 4 месяца назад
Thank you :D
@ivanaksmsk
@ivanaksmsk 3 года назад
Thank you!
@simpson6700
@simpson6700 3 месяца назад
strange that this signal wouldn't include a reference to the node that was just clicked on. i have the Area3D send a signal to my camera and i want to detect which object i last clicked on to make the camera orbit around that object.
@pspspsp5
@pspspsp5 19 дней назад
Thank you
@Galaxy-pm2ff
@Galaxy-pm2ff 3 года назад
sorry, how do I make the button with mouse mode captured on? nice tutorial by the way
@gd7681
@gd7681 3 года назад
Thanks for the tutorial. What is the purpose of creating the Sphere Spatial node instead of just creating the Sphere meshinstance directly?
@DavetheDev
@DavetheDev 3 года назад
Good question. You can use the MeshInstance directly if you want. By habit I create things using a principle called "Separation of concerns" en.wikipedia.org/wiki/Separation_of_concerns In which each object has a specific job. In this case, the Spatial Node's job is to encapsulate an "entity" in the game world, and the job of the MeshInstance is only to display what the entity looks like. In simple examples like this, it doesn't much matter, but as things get more complex, Separation of Concerns becomes really important. I didn't really think about all that when I made this though, like I said, it was mostly because of habit.
@mirohorvath
@mirohorvath 4 года назад
thank you
@kedalovo8576
@kedalovo8576 4 года назад
Sorry to ask something that might be unrelated, but I don't know how to solve this: I have a 2d scene, which has a Viewport in it to show a 3d object in this scene. Now, if I understand correctly, there is no way to actually make that object clickable using Viewport, because, basically, I use the Viewport to get texture from this object. Maybe there is actually a way to make the texture clickable, but I don't know about it. Do you mind sharing the solution if there is one?
@DavetheDev
@DavetheDev 4 года назад
Off the top of my head, use a TextureRec to display the texture from the Viewport. When you click the TextureRec, you'll get an InputEvent for via the "gui_event" signal. Take that event and manually translate it into a new event that will be picked up by the 3D Area node of your 3D object. You can fire fake events down the node tree by via the SceneTree. So, in psudocode it would be this... 1. Capture the click event postion on the TextureRec. 2. Translate the click position from the TextureRec coords into the 3D camera's screen-space coords. 3. Make a new instance of an InputEvent and put the screen-space coords in its properties. 4. Fire the custom "fake" InputEvent down the NodeTree via the SceneTree. 5. Pickup the InputEvent in the 3D object's Area node like normal via it's InputEvent signals as shown in the video. I haven't done it myself, but I'd be curious to learn how it goes...
@kedalovo8576
@kedalovo8576 4 года назад
@@DavetheDev Thank you very much for the answer! I will try this some time soon and return in any case (success/failure). Just started learning Godot like 2 days ago, so this is unbelievably helpful
@kedalovo8576
@kedalovo8576 4 года назад
@@DavetheDev OK, I got stuck on the second step (a bit further than I thought). I successfully understood how to get the position of click, but have no idea how to get these coordinates go to function inside my 3D scene. Tried to call that function from the main scene inserting click_position, but got so many mistakes that I don't think I am doing anything correctly. Sorry for taking your time, but if you could spare some, would you mind explaining it a bit more down-to-earth?
@DavetheDev
@DavetheDev 4 года назад
@@kedalovo8576 Explaining is a bit complicated, but it's an interesting problem, so I made an example demo instead. Download and Setup this Godot project: github.com/EXPWorlds/Godot-Tutorials Under the "8 Clicking 3D Objects" folder is a Supplementary folder and another folder with your youtube user name. Load the "Demo" scene and run it with F6. Hope that helps better than my rambling explanations. ^_^ Let me know how things go.
@kedalovo8576
@kedalovo8576 4 года назад
@@DavetheDev Thank you very much, I'm amazed by the fact you are still willing to help me. I hope that what you have already given is enough to figure things out by myself.
@logangraham2956
@logangraham2956 4 года назад
i am having a bit of an issue clicking these area nodes through my players hud , if i turn off my huds visibility i can click the area nodes but if the hud is visible then i am not able to click the area nodes. how do i get my clicks to go through my hud? its a control node
@DavetheDev
@DavetheDev 4 года назад
In the Inspector, Control derived nodes have a "Mouse" menu. Under that menu there is a "filter" drop down with the options, "Stop, Pass, Ignore". Try changing those filter options.
@logangraham2956
@logangraham2956 4 года назад
@@DavetheDev i actually tried that setting once and thought it was useless XD i set it to pass and it did nothing. i tried ignore this time and it worked. that so weird , I'd think that "pass" = "pass-through".
@DavetheDev
@DavetheDev 4 года назад
@@logangraham2956 Yeah, it can be a bit misleading. Glad you got it to work. The "pass" option actually captures mouse input, but if the control node that was clicked doesn't handle the input it will Pass the event along to a parent control node, if there is one. At least that's what the documentations says...
@logangraham2956
@logangraham2956 4 года назад
@@DavetheDev my next challenge is getting proper camera rotation and then maybe figuring out procedural generation for infinite ground my current solution is to exported a vector3 which i set to equal my velocity and then i just move the ground on the x+z so it always stays under the player. its a temp fix but it'll hold till i figure out how to generate ground from code instead of manually placing every single block.
@black_forest_
@black_forest_ 2 месяца назад
Nothing happened, is it different in Godot 4? I assume so since for example the ray bool was already enabled
@DavetheDev
@DavetheDev 2 месяца назад
Yes, it was made for Godot 3. Thanks for the feedback. I've changed the title of the video to reflect that it only works in Godot3.
@davy-cx3vu
@davy-cx3vu 3 года назад
Thanks
@gyattrizzV
@gyattrizzV 8 месяцев назад
I have input ray pickable on and I cant make the on input event work at all
@Hajdew
@Hajdew 4 года назад
Great video! But why there are 2 mouse cursons at 1:09?
@DavetheDev
@DavetheDev 4 года назад
lol nice eyes. Sometimes when I'm editing the videos, there is too much to say and not enough video, so I take a screenshot of the video to pause it while explaining something. During the screenshot, sometimes my mouse gets in the way. So, there is the mouse on the video and the mouse when I take a screenshot. Now that someone has noticed, I'll either find a better way to pause the video, or.....just have everyone play Where's Waldo with mouse cursors....hahhaah
@Hajdew
@Hajdew 4 года назад
@@DavetheDev i know in sony vegas is a screen shot option but idk which software do you use.Also im a big fan of yours intro's
@DavetheDev
@DavetheDev 4 года назад
@@Hajdew I use Blender for video editing. I learned if you press F12, blender will render the current frame as an image that can be imported back into the video editor. Thanks to you, I learned something new. :) As for the intro, I used to do a lot of programming on the TI-83+ calculator when I was a kid, so what you're seeing is a TI program running on an emulator, glad you like it.
@moric4677
@moric4677 4 года назад
that's illuminati
@kohrakvaza
@kohrakvaza 4 года назад
Thanks for the tutorial. Trying the demo, it seems like the spheres all change color when clicking one of them, instead of changing individually.
@DavetheDev
@DavetheDev 4 года назад
That's because all three of your spheres probably share the same material. Right click on the material and select "Make Unique". When you duplicate things in Godot, the duplicates share any sub-resources like textures, shaders, materials, curves, etc. unless told not to.
@iamlordstarbuilder5595
@iamlordstarbuilder5595 Год назад
Any idea how to detect whether it is clicking away? Would be nice to deselect something in the same way I selected it.
@DavetheDev
@DavetheDev Год назад
Can do. When you select something add it to a list of selected things. When you click again anywhere on the screen, iterate through the list of selected things, deselect them and remove them from the list before checking if something new was selected.
@iamlordstarbuilder5595
@iamlordstarbuilder5595 Год назад
@@DavetheDev I actually went with something different, I added a boolean that the selected object flips when clicked and then the next frame is flipped back off, only way to turn it on again is to select an object. Your solution works for multiple objects ig, but I’m only selecting one at a time in my game
@DavetheDev
@DavetheDev Год назад
@@iamlordstarbuilder5595 Sweet!
@leonseghesso3539
@leonseghesso3539 7 месяцев назад
Funciona para juegos en Android?
@kishonoi191
@kishonoi191 3 года назад
what about with a crosshair?
@flyingjudgement
@flyingjudgement 8 месяцев назад
Hi, is any one know how to call this type of functions from C#?
@justOne503
@justOne503 6 месяцев назад
using Godot; using System; public class YourClassName : Node3D { public override void _Input(InputEvent @event) { if (@event is InputEventMouseButton mouseButtonEvent) { if (mouseButtonEvent.ButtonIndex == (int)ButtonList.Left && mouseButtonEvent.Pressed) { GD.Print("Pressed Left Mouse Button"); } } } } Try this.
@christianbatista0
@christianbatista0 Год назад
FU thx so much
Далее
I Made the Same Game in 8 Engines
12:34
Просмотров 3,8 млн
Пробую торты
00:43
Просмотров 240 тыс.
Tragic Moments 😥 #2
00:30
Просмотров 4 млн
Simplifying Godot UI Development for All Levels
24:22
How to Code (almost) Any Feature
9:48
Просмотров 638 тыс.
i got laid off... so i made a game...
24:08
Просмотров 596 тыс.
I Optimised My Game Engine Up To 12000 FPS
11:58
Просмотров 484 тыс.
We made Vampire Survivors BUT in 10 Lines of Code
7:08
Dear Game Developers, Stop Messing This Up!
22:19
Просмотров 676 тыс.
13 ADDONS to SPEED UP your game creation in GODOT!
11:23
8 DEVS Make a GAME without COMMUNICATING!
13:21
Просмотров 964 тыс.
Я МАААРС  #dota2
0:40
Просмотров 53 тыс.
104000 🏆❤️
0:38
Просмотров 755 тыс.
try to go to the toilet in time 🚽?
0:12
Просмотров 310 тыс.