Laser beams in Godot 3.2 (using a RayCast2D)

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

КОМЕНТАРІ • 63

  • @RedEyedJedi
    @RedEyedJedi 6 місяців тому +3

    This isn't just a great tutorial. it's also a great lesson on how to program. First, know exactly what you want to achieve. Secondly, divide that problem into many smaller problems and then start solving these smaller problems until you have completed the bigger problem. Thank you for the video. It was very helpful.

  • @uheartbeast
    @uheartbeast  4 роки тому +5

    Hope you all enjoy the video! I'm going to start uploading Godot Action RPG videos next week!
    Here is the original article by Kemono Games (it was made using Godot 2 I think): kemonogames.tumblr.com/post/145440294136/how-to-create-plasma-beams
    Kemono Games' Twitter: twitter.com/KemonoGames
    Have a great weekend! - Ben
    P.S. If you haven't checked it out yet, here is my Godot course: www.heartgamedev.com/1-bit-godot-course-youtube
    [edit] forgot to link to the github for the source code/resources: github.com/uheartbeast/youtube-tutorials

  • @TimmyBobimmy
    @TimmyBobimmy 4 роки тому +22

    Hey dude your content is super awesome, and you inspired me to stick with the Godot engine when I was about to uninstall it, and now I love using it to make games. Keep up the great content. Thanks.

  • @AniMesuro
    @AniMesuro 4 роки тому +10

    Thank you so much. I've been trying to figure out how to make art-heavy backgrounds with polygons, as in Once Upon a Coma, and didn't know how to start. Never thought about stealing CollisionPolygon2D's polygon to Polygon2D from a script.
    Didn't expect to learn it from a laserbeam tutorial tho.
    Now with this in mind I think I'll try to make a script to fill the border with grass sprites.

    • @antonioedmilson1810
      @antonioedmilson1810 4 роки тому

      You can make the collision polygon2D follow the sprite length? helpppp

    • @kmeadows100
      @kmeadows100 2 роки тому

      Agreed. That little 10 second trick saved countless people countless time.

  • @adamsmiddy
    @adamsmiddy 4 роки тому +23

    "Good morning, afternoo-" presses like cause HeartBeast

  • @braveblade87
    @braveblade87 5 місяців тому +2

    In GODOT 4.0 RayCast's cast_to was renamed to target_position

  • @vigneshs2886
    @vigneshs2886 4 роки тому +5

    Good lord I was literally searching for this yesterday and I couldn't find it. It seems like you made this video just for me lol. Thanks a lot.

  • @nabilandadamslaboratory3422
    @nabilandadamslaboratory3422 4 роки тому +1

    Please keep with the Godot videos! Gamemaker is outclassed now.

  • @mertgulec7541
    @mertgulec7541 7 місяців тому +1

    Still useful. I am glad this tutorial exists because all other are just copy paste and no explanation

  • @Ric_93
    @Ric_93 4 роки тому +3

    I needed this! Thank you so much Benjamin!!

    • @uheartbeast
      @uheartbeast  4 роки тому +5

      You're welcome! I love your videos. It's good to see you here :)

    • @Ric_93
      @Ric_93 4 роки тому +3

      @@uheartbeast oh wow, thank you for watching! You're the one who initiated me to pixel art! ☺️ I bought all your pixel art courses on Udemy! I made my very first pixel art sprites watching your tutorials

  • @davidphillips9366
    @davidphillips9366 4 роки тому +1

    Thanks for such great tutorials! I've always been interested in game development but I had never tried it until I started watching your videos. Im so glad you take the time to explain why things work the way they do and you don't just right a bunch of code and then vaguely explain what it all does.

  • @TackerTacker
    @TackerTacker 4 роки тому +4

    Great tutorial. I think you should post your videos on the Godot discord, they have a channel for sharing tutorials.

  • @KlausWulfenbach
    @KlausWulfenbach 4 роки тому +2

    Time to add a laser weapon to my Metroidvania game!

  • @kennethmkline23
    @kennethmkline23 4 роки тому +1

    I really miss your Gamemaker tutorials :)

  • @jinshiro
    @jinshiro 4 роки тому

    Planned to add mining lasers to my game today, perfect timing. Now I have a reference for implementation.

  • @tomf4927
    @tomf4927 3 роки тому +3

    Thanks for this! However, I discovered a little problem. The raycast stops while the beam image continues to extend itself if it isn't colliding. I solved this by altering the if/else statements. if colliding: beam.region_rect.end.x = end.position.length(), else: beam.region_rect.end.x = end.global_position.length()

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

      I followed the tutorial and edited parts for Godot 4.0. This solved an issue of the beam being too short. 😄

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

      If you have a larger window then you have to make the max_cast_to variable larger or the beam will ignore collisions because the raycast is too short and it will treat it as an else statement.

  • @CamiloS2001
    @CamiloS2001 2 роки тому +1

    thank you

  • @stevenjadamo
    @stevenjadamo 4 роки тому

    Definitely filing this one aware for future use... thanks Ben!

  • @michaelcapone175
    @michaelcapone175 4 роки тому +1

    Great tutorial Ben. Taught me something. Thank you.

  • @RDHardy79
    @RDHardy79 4 роки тому +7

    For me, and I followed absolutely ever single step twice (I started all over again the first time this problem happened) but every time I try to run the game from the world scene with the collision objects in place, the laser doesn't track the mouse. Tracks it just fine in the laser scene but not in the world scene.
    The error :
    Line 9 (UNUSED_ARGUMENT):The argument 'delta' is never used in the function '_physics_process'. If this is intended, prefix it with an underscore: (ignore) '_delta'
    The debugger states: Invalid call. Nonexistent function 'get_Collision_point' in base 'RayCast2D.
    Mind you, the code is identical what gives?
    Okay so, I figured it out as I was composing this. I'm keeping this comment to maybe help others. 'get_Collision_point' is invalid due to the simple fact that there is no such thing as get_Collision_point in GDOT, there is a get_collision_point.SEE IT?? I had Collision capitalized and thus the whole code was bunk. that is stupid as hell, but oh well. I'm learning. Thanks for the videos.

    • @uheartbeast
      @uheartbeast  4 роки тому +5

      Thanks for posting this to help others. Small typos like that are very common and can be super frustrating. Everyone makes them and it is part of learning to code. I'm glad you were able to work it out.

  • @ivanzelta3609
    @ivanzelta3609 3 роки тому

    I LOVE THIS GUY

  • @antonioedmilson1810
    @antonioedmilson1810 4 роки тому +1

    Thank you so much!

  • @Aahaah8
    @Aahaah8 4 роки тому

    Thank you so much for this tutorial, this is exactly what I've been looking for! So simply explained, you are awesome!

  • @mazimadu
    @mazimadu 4 роки тому +2

    Looks like you have been making good progress using Godot.
    How do you feel it fairs compared to GameMaker studio 2?

  • @th-bl7fd
    @th-bl7fd 5 місяців тому

    Thank you.

  • @JimmyCrackorn
    @JimmyCrackorn 4 роки тому

    Will you do a follow-up to go over setting up the beam to reflect off of surfaces when there's a collision and making it respond to input instead of always being on?

  • @covereye5731
    @covereye5731 Рік тому

    Not sure how you would use region rect that way if you were pulling the beam from a spritesheet.

  • @ghb323
    @ghb323 3 роки тому

    Not to be confused as a short laser projectile that travels A LOT slower.

  • @mahmoud.zayedd
    @mahmoud.zayedd 4 роки тому

    Hope do the same in Game maker 💙

  • @IndieLibre
    @IndieLibre 4 роки тому

    Muchas gracias!

  • @ZetaCarinae
    @ZetaCarinae 4 роки тому

    Super helpful thank you!

  • @antonioedmilson1810
    @antonioedmilson1810 4 роки тому +1

    You can helpe me? My laser have a Collision Polygon2D, and i want to that Polygon2D too extends to the collision point of raycast, same of sprite. Can you helpe please?
    love your videos

  • @user-wb5xj7oq5w
    @user-wb5xj7oq5w 4 роки тому

    Thank you so much for this

  • @kylin3197
    @kylin3197 4 роки тому

    very cool! awesome vid!

  • @cristianinujazznight3044
    @cristianinujazznight3044 4 роки тому

    Thank you for the video.

  • @veltsu9
    @veltsu9 4 роки тому

    That is very handy! +1
    Now I wonder how would a laser beam work, which gets reflected from the walls...?

  • @Nizrab
    @Nizrab 2 роки тому +1

    1:21 pov you use icon.png

  • @Gost-nf3cr
    @Gost-nf3cr 4 роки тому +1

    do you can make a download of all your tutorial projekts that would be very nice

    • @halobread
      @halobread 3 роки тому +1

      no its a tutorial
      you're meant to learn not steal

    • @Gost-nf3cr
      @Gost-nf3cr 3 роки тому

      @@halobread i do learn better by messing around with stuff

  • @DrNabeel20
    @DrNabeel20 4 роки тому

    Thank you this is amazing! 💯💯

  • @MM-ym8kk
    @MM-ym8kk 4 роки тому

    why multiplying by MAXLENGHT if you going to use normalized() will it not be scaled to 1
    var max_cast_to = mouse_postion.normalized() * MAX_LENGHT

  • @seewhale8565
    @seewhale8565 4 роки тому

    Hi Ben, could you redo the top-down rpg in Godot which you previously did in Gamemaker?

  • @jackwinner4810
    @jackwinner4810 4 роки тому

    Hello Mr. HeartBeast thank you very much for your Tutorial. I don't
    I don't undestand english but I understand all that you did.
    You inspirate me to do VideoGames
    Thank you very much and God Bless you and your family!!!!

  • @candicerichter8910
    @candicerichter8910 3 роки тому

    I have a problem. none of the recommended fixes stop it. the raycast doesn't collide with the walls and the endpoint never moves more than 100 pixels away. Thanks!
    okay, so I kinda fixed it. it still extends the beam too far but the endpoint is in the right spot. apparently, putting it on a moving sprite doesn't work very well.
    okay, so I fixed the problem with the sprite, turns out it was colliding with its hitbox. I still cant fix the problem with the beam though.
    also, how do I turn the beam on and off?

  • @Joshua-kr5fq
    @Joshua-kr5fq 4 роки тому

    when will you be doing networking?

  • @NidonocuPoisonBunny
    @NidonocuPoisonBunny 4 роки тому

    Can I ask how Godot is configured to remove 3D related things?

  • @tjwinn4931
    @tjwinn4931 4 роки тому +1

    Pogchamp

  • @CAl_9000
    @CAl_9000 4 роки тому

    Curiously this doesnt work when instanced as a child of my player character but works fine when instanced directly in the world

    • @rhysjones8105
      @rhysjones8105 Рік тому

      Very late to this, but did you set the collision layer of your player to be separate from the collision mask of the laser?

  • @godonholiday
    @godonholiday 4 роки тому

    Quality

  • @KFSENSEI
    @KFSENSEI 4 роки тому +2

    like

  • @pompyproductions5644
    @pompyproductions5644 3 роки тому +1

    ~wherever and whenever you are, my name is Benjamin~ _here have a like_

  • @me2beats313
    @me2beats313 4 роки тому

    Cool:)

  • @Archive-w5s
    @Archive-w5s 4 роки тому

    the like/dislike ratio tho ....