Godot Ray-casting tutorial: Create a simple Hitscan Weapon

Поділитися
Вставка
  • Опубліковано 20 жов 2024

КОМЕНТАРІ • 34

  • @Teckstudio
    @Teckstudio Рік тому +3

    Wow, excellent. 🤩 Straight to the point. Super simple example. Perfect to follow along. Great Work, keep on going!!! 😍

  • @PollyCot
    @PollyCot Рік тому +3

    Been a big help honestly thanks

  • @tessytocaliente
    @tessytocaliente Рік тому +4

    Thx for the amazing tutorials!

  • @Hand2024
    @Hand2024 Рік тому +3

    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  Рік тому +2

      Thank you 😊. Although I’m still on holiday I found this buried in my unlisted haha.

    • @Hand2024
      @Hand2024 Рік тому +1

      @@Chaff_Games Ahhh well enjoy your holiday then haha 😆 thank you either way

  • @devwiktor
    @devwiktor 2 місяці тому

    Thanks! Currently switching from Unity to Godot. Very useful :D

  • @The_Dialect
    @The_Dialect Рік тому +3

    Great video! ❤❤

  • @TechCowboy
    @TechCowboy 11 місяців тому +1

    This is gold!

  • @NOGRDA
    @NOGRDA Рік тому +1

    Goated Tut

  • @MeestahBinks
    @MeestahBinks 10 місяців тому +2

    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  10 місяців тому +1

      I have a way of doing it. I’ll see if I can condense it down into a video.

    • @MeestahBinks
      @MeestahBinks 10 місяців тому

      @@Chaff_Games that would be fantastic. thank you for your quick reply as well.

  • @LiteralPain3551
    @LiteralPain3551 9 місяців тому +1

    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  9 місяців тому

      You can ray cast off any node3d the to and from can be anywhere you like.

    • @LiteralPain3551
      @LiteralPain3551 9 місяців тому

      @@Chaff_Games ty for responding! i cant seem to get a position in front of the correct node though

  • @agoogleuser6556
    @agoogleuser6556 4 місяці тому

    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

  • @starwatcher4708
    @starwatcher4708 8 місяців тому +1

    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  8 місяців тому

      Yes, I don’t even think you wool need to manipulate the position just straight ahead and the rang is your cast to.

  • @inn5268
    @inn5268 9 місяців тому +1

    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  9 місяців тому +1

      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 9 місяців тому

      ​@@Chaff_Games thnx I'll check which one performs better

  • @GameDev-gq2zk
    @GameDev-gq2zk 6 місяців тому +1

    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  6 місяців тому +1

      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 6 місяців тому

      @@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

  • @donvarsmak5688
    @donvarsmak5688 Місяць тому +1

    Thank you, Charlie from Smiling Friends

  • @octocrane3155
    @octocrane3155 6 місяців тому

    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  6 місяців тому

      Are you using jolt? By default godot physics has hit from inside turned off. But jolt has it turned on.

    • @octocrane3155
      @octocrane3155 6 місяців тому

      @@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 6 місяців тому +1

    ✨🙏🏼✨

  • @bnkm07
    @bnkm07 6 місяців тому +2

    how to make it damage and stuff-

    • @Chaff_Games
      @Chaff_Games  6 місяців тому

      Check my channel I have a lot more on this topic.

    • @bnkm07
      @bnkm07 6 місяців тому

      @@Chaff_Games ok thx

  • @Boildroid
    @Boildroid Рік тому +5

    Thank you for tutorial.