this is a great tutorial but i have been struggling to add some variation in trajectory with a hitscan weapon. it seems like every tutorial fails to mention how to make hitscan weapons not laser accurate. If you have any resources that could help me with this issue that would be great and I really love your godot tutorials.
how might i achieve this without a camera? im trying to use a starting nodes position, however, whenever i try and get the forward direction of the node it seems create the ray from the center of the world. im unsure how to solve this. any ideas? thanks
I followed this tutorial but when the ray is shot at something with collision it doesn't report it and print it to the terminal. it just prints "nothing". I don't know what I did wrong
I believe this is a common use case. I use area 3d to scan a general area and once the player enters that area I start ray casting. Rather than doing it all the time. The best way to find out if it affects performance is to do it and see if it does. You gotta stress test your use case and see if it is a problem before you know.
I'm so unbelievably confused by lines 15 and 16 So you put the newly created PhysicsRayQueryParameters3D object into a var called New_Intersection. I've been reading through the docs trying to understand this line specifically. As well as the line after it. From reading the docs it seems like "New_intersection" being a PhysicsRayQueryParameters3D object is just the Ray?? It isn't, I don't think, otherwise we would just call it Ray instead of New_Intersection (I assume) - So is New_intersection just an instance of the PRQP3D class that contains all of the things that the Ray collided with? After this you create Intersection, I gather that the code here takes the PRQP3D object and returns a dictionary of things about an intersection with the PRQP3D/Ray object but I don't understand how this works? everything else makes total sense but these two lines simply do not compute after an hour thumbing through the documentation. like does the intersect_ray() method return the first collider that the ray intersects? if the ray intersects multiple objects could I get the second instead?
To be honest, I've never given it that much thought. There's not a lot being said in the docs on the PRQP3D. As far as I understand it the PRQP3D doesn't do anything. It's just a class for defining what the ray will do. You pass that to the direct space 3d object so it knows what to do. When you call 'get_world_3d().direct_space_state' you're access the physics server. It needs information from the PRQP3D to do a ray cast. The direct space state is the object that casts a ray and returns the collisions. How it works is probably not something you need to worry about if you're just making a game. If want to learn more about how ray casting works at a lower level then that's great. You should check out The Cherno. He makes content on those kinds of things.
@@Chaff_Games Hero, thank you so much. I was trying to figure out if I'm just getting way to deep into an unnecessary topic and I think I am but I still do want to know more hahaha but I'll probably put it on the back burner. Thank you and I'll definitely check out the cherno
@@Chaff_Games I managed to fix it. Thanks for helping anyway. No I wasn’t using jolt physics but I’ll keep that in mind if I use it in future projects.
Wow, excellent. 🤩 Straight to the point. Super simple example. Perfect to follow along. Great Work, keep on going!!! 😍
Been a big help honestly thanks
Thx for the amazing tutorials!
Welcome back from holiday mate I like just listening you your content while I work on my projects in godot your a talented dev 😊
Thank you 😊. Although I’m still on holiday I found this buried in my unlisted haha.
@@Chaff_Games Ahhh well enjoy your holiday then haha 😆 thank you either way
Thanks! Currently switching from Unity to Godot. Very useful :D
Great video! ❤❤
This is gold!
Goated Tut
this is a great tutorial but i have been struggling to add some variation in trajectory with a hitscan weapon. it seems like every tutorial fails to mention how to make hitscan weapons not laser accurate. If you have any resources that could help me with this issue that would be great and I really love your godot tutorials.
I have a way of doing it. I’ll see if I can condense it down into a video.
@@Chaff_Games that would be fantastic. thank you for your quick reply as well.
how might i achieve this without a camera? im trying to use a starting nodes position, however, whenever i try and get the forward direction of the node it seems create the ray from the center of the world. im unsure how to solve this. any ideas? thanks
You can ray cast off any node3d the to and from can be anywhere you like.
@@Chaff_Games ty for responding! i cant seem to get a position in front of the correct node though
I followed this tutorial but when the ray is shot at something with collision it doesn't report it and print it to the terminal. it just prints "nothing". I don't know what I did wrong
Hi, Thanks for the tutorial, is it possible to get this result by creating a Raycast3D in the camera3D and manipulating its target_position?
Yes, I don’t even think you wool need to manipulate the position just straight ahead and the rang is your cast to.
I want to constantly cast a ray to alert npcs if they're in the player's line of sight, would this affect performance too much?
I believe this is a common use case. I use area 3d to scan a general area and once the player enters that area I start ray casting. Rather than doing it all the time.
The best way to find out if it affects performance is to do it and see if it does. You gotta stress test your use case and see if it is a problem before you know.
@@Chaff_Games thnx I'll check which one performs better
I'm so unbelievably confused by lines 15 and 16
So you put the newly created PhysicsRayQueryParameters3D object into a var called New_Intersection.
I've been reading through the docs trying to understand this line specifically. As well as the line after it.
From reading the docs it seems like "New_intersection" being a PhysicsRayQueryParameters3D object is just the Ray??
It isn't, I don't think, otherwise we would just call it Ray instead of New_Intersection (I assume) - So is New_intersection just an instance of the PRQP3D class that contains all of the things that the Ray collided with?
After this you create Intersection, I gather that the code here takes the PRQP3D object and returns a dictionary of things about an intersection with the PRQP3D/Ray object but I don't understand how this works?
everything else makes total sense but these two lines simply do not compute after an hour thumbing through the documentation.
like does the intersect_ray() method return the first collider that the ray intersects? if the ray intersects multiple objects could I get the second instead?
To be honest, I've never given it that much thought.
There's not a lot being said in the docs on the PRQP3D. As far as I understand it the PRQP3D doesn't do anything. It's just a class for defining what the ray will do. You pass that to the direct space 3d object so it knows what to do. When you call 'get_world_3d().direct_space_state' you're access the physics server. It needs information from the PRQP3D to do a ray cast. The direct space state is the object that casts a ray and returns the collisions. How it works is probably not something you need to worry about if you're just making a game. If want to learn more about how ray casting works at a lower level then that's great. You should check out The Cherno. He makes content on those kinds of things.
@@Chaff_Games Hero, thank you so much. I was trying to figure out if I'm just getting way to deep into an unnecessary topic and I think I am but I still do want to know more hahaha but I'll probably put it on the back burner. Thank you and I'll definitely check out the cherno
Thank you, Charlie from Smiling Friends
This is a great video, but the raycast sometimes detects the character's collision box.
How do I stop this from happening
Edit: nvm figured out how
Are you using jolt? By default godot physics has hit from inside turned off. But jolt has it turned on.
@@Chaff_Games I managed to fix it. Thanks for helping anyway.
No I wasn’t using jolt physics but I’ll keep that in mind if I use it in future projects.
✨🙏🏼✨
how to make it damage and stuff-
Check my channel I have a lot more on this topic.
@@Chaff_Games ok thx
Thank you for tutorial.