No video

Godot Ray-casting tutorial: Create a simple Hitscan Weapon

  Рет қаралды 9,214

Chaff Games

Chaff Games

Күн бұрын

Raycasting in Godot is a very important technique to know and understanding. The main class we're looking at today is PhysicsRayQueryParameters3D. PhysicsRayQueryParameters3D is a class that has been introduced as of Godot 4. It needs to be used in conjuction with the Direct Space State. By combining both you can easily ray cast from the camera or any other object you want.
In this simple tutorial we will use it to create a very simple hitscan weapon but this can also be used for a wide array of other things in you game as well, for example enemy vision.
Support the Channel: / chaffgames
Join The Discord: / discord
My Latest Course: www.udemy.com/...
Get the FPS Template Here: chaffgames.com...
---------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
Please like and Subscribe! It's truly appreciated
#GameDevelopment #GameJam #Godot
Links to my Socials
Instagram: / chaff.dev
Twitter: / chaffdev
Itch.io: chafmere.itch.io/
Website: chaffgames.com

Пікірлер: 33
@slowbirdgames
@slowbirdgames Ай бұрын
Thanks! Currently switching from Unity to Godot. Very useful :D
@Teckstudio
@Teckstudio 11 ай бұрын
Wow, excellent. 🤩 Straight to the point. Super simple example. Perfect to follow along. Great Work, keep on going!!! 😍
@PollyCot
@PollyCot 11 ай бұрын
Been a big help honestly thanks
@tessytocaliente
@tessytocaliente 11 ай бұрын
Thx for the amazing tutorials!
@Hand2024
@Hand2024 11 ай бұрын
Welcome back from holiday mate I like just listening you your content while I work on my projects in godot your a talented dev 😊
@Chaff_Games
@Chaff_Games 11 ай бұрын
Thank you 😊. Although I’m still on holiday I found this buried in my unlisted haha.
@Hand2024
@Hand2024 11 ай бұрын
@@Chaff_Games Ahhh well enjoy your holiday then haha 😆 thank you either way
@The_Dialect
@The_Dialect 11 ай бұрын
Great video! ❤❤
@GameDev-gq2zk
@GameDev-gq2zk 4 ай бұрын
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?
@Chaff_Games
@Chaff_Games 4 ай бұрын
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.
@GameDev-gq2zk
@GameDev-gq2zk 4 ай бұрын
@@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
@agoogleuser6556
@agoogleuser6556 3 ай бұрын
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
@MeestahBinks
@MeestahBinks 9 ай бұрын
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.
@Chaff_Games
@Chaff_Games 9 ай бұрын
I have a way of doing it. I’ll see if I can condense it down into a video.
@MeestahBinks
@MeestahBinks 9 ай бұрын
@@Chaff_Games that would be fantastic. thank you for your quick reply as well.
@TechCowboy
@TechCowboy 10 ай бұрын
This is gold!
@NOGRDA
@NOGRDA 11 ай бұрын
Goated Tut
@starwatcher4708
@starwatcher4708 6 ай бұрын
Hi, Thanks for the tutorial, is it possible to get this result by creating a Raycast3D in the camera3D and manipulating its target_position?
@Chaff_Games
@Chaff_Games 6 ай бұрын
Yes, I don’t even think you wool need to manipulate the position just straight ahead and the rang is your cast to.
@LiteralPain3551
@LiteralPain3551 8 ай бұрын
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
@Chaff_Games
@Chaff_Games 8 ай бұрын
You can ray cast off any node3d the to and from can be anywhere you like.
@LiteralPain3551
@LiteralPain3551 8 ай бұрын
@@Chaff_Games ty for responding! i cant seem to get a position in front of the correct node though
@inn5268
@inn5268 7 ай бұрын
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?
@Chaff_Games
@Chaff_Games 7 ай бұрын
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.
@inn5268
@inn5268 7 ай бұрын
​@@Chaff_Games thnx I'll check which one performs better
@octocrane3155
@octocrane3155 5 ай бұрын
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
@Chaff_Games
@Chaff_Games 5 ай бұрын
Are you using jolt? By default godot physics has hit from inside turned off. But jolt has it turned on.
@octocrane3155
@octocrane3155 5 ай бұрын
@@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.
@santoshgujar5237
@santoshgujar5237 5 ай бұрын
✨🙏🏼✨
@bnkm07
@bnkm07 4 ай бұрын
how to make it damage and stuff-
@Chaff_Games
@Chaff_Games 4 ай бұрын
Check my channel I have a lot more on this topic.
@bnkm07
@bnkm07 4 ай бұрын
@@Chaff_Games ok thx
@Boildroid
@Boildroid 11 ай бұрын
Thank you for tutorial.
Signals in Godot are Amazing!
5:17
Chaff Games
Рет қаралды 28 М.
Godot 4 - Tiled Dungeon Environment From Scratch
26:24
DevLogLogan
Рет қаралды 415 М.
Or is Harriet Quinn good? #cosplay#joker #Harriet Quinn
00:20
佐助与鸣人
Рет қаралды 46 МЛН
The CUTEST flower girl on YouTube (2019-2024)
00:10
Hungry FAM
Рет қаралды 39 МЛН
PEDRO PEDRO INSIDEOUT
00:10
MOOMOO STUDIO [무무 스튜디오]
Рет қаралды 24 МЛН
3 Devs Make An FPS - Godot vs Unity vs Unreal || GameDev Battles
12:39
The Most Impressive Scratch Projects
11:00
DenshiVideo
Рет қаралды 4,9 МЛН
Giving Personality to Procedural Animations using Math
15:30
t3ssel8r
Рет қаралды 2,5 МЛН
I Made My First Game in Godot in 3 Weeks...
26:21
Jack Sather
Рет қаралды 335 М.
10+2 AWESOME ADDONS for GODOT 4
8:36
MrElipteach
Рет қаралды 140 М.
You're not using Godot to its potential
6:12
Tienne_k
Рет қаралды 92 М.
Do THIS Before You Publish Your Godot Game
3:33
StayAtHomeDev
Рет қаралды 167 М.
How To Make A Doom Clone In Godot 4
27:57
MizizizizTutorials
Рет қаралды 77 М.
When Your Game Is Bad But Your Optimisation Is Genius
8:52
Vercidium
Рет қаралды 1,5 МЛН
Or is Harriet Quinn good? #cosplay#joker #Harriet Quinn
00:20
佐助与鸣人
Рет қаралды 46 МЛН