Learn Raycasting in 7 minutes - Advanced Roblox Scripting

Поділитися
Вставка
  • Опубліковано 8 чер 2024
  • MERCH ► shop.gnome.codes/
    DISCORD ► / discord
    TWITCH ► / gnomecode
    TWITTER ► / gnomecoderblx
    WEBSITE ► gnome.codes/
    TIMESTAMPS ►
    0:00 Intro
    0:32 Simple raycasts
    3:00 Altering the hit part
    3:41 Filtering results
    5:25 Looping
    6:47 Outro

КОМЕНТАРІ • 217

  • @godssilliestsoldier249
    @godssilliestsoldier249 Рік тому +41

    just realized with this i can make pizza tower's "dont make a sound" mechanic. this is going to be so cool

    • @pe_w
      @pe_w 11 місяців тому

      Can you explain this more if sounds like an interesting concept

    • @anotherdeadchannel
      @anotherdeadchannel 11 місяців тому

      ​@@pe_wI think depending on the distance they won't make a sound

    • @RammansPizzas
      @RammansPizzas 10 місяців тому +4

      ​@@pe_wIn the Level they are Patrollers going around and if you get spotted, they count down from 5, giving you time to kill them and if it hits 0 then a Animatronic will start chasing you.

    • @Spez_art
      @Spez_art 3 місяці тому +3

      You don't need raycasting to do that. You can just use .magnitude to see the distance between the positions of their root parts.

  • @eliseyzscripts6762
    @eliseyzscripts6762 Рік тому +2

    BRO thank you so much! i am glad i found you because the first thing you said was "how to check if part can see another part" and this is exactly what i was searching for!

  • @Trashbinfin
    @Trashbinfin 10 місяців тому +3

    Thanks! A lot more simple than i thought! You are very underrated.

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

    Nice explained and simple, now I can make stuff like you have to move a part until it sees the other part to open a door!

  • @workindad
    @workindad Рік тому +10

    Excellent tutorial. I’ve been working on raycasting in my game and have been unfamiliar with how the ray is being generated/set. This vid answers a lot of questions. Ty.

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

    Thank you. I have been really confused with raycasting. Now I fully understand how it works. Thanks GnomeCode!

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

    Thank you most tutorials are outdated or confusing this helped alot

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

    thank you so much for this man. i cant describe in words how thankful i am

  • @dr.albitros4242
    @dr.albitros4242 Рік тому +1

    The perfect video! Haven't watch it whole yet, but surely it will be good! :)

  • @killa5963
    @killa5963 10 місяців тому +12

    This is incredibly helpful, but the only problem is it's the position of the part, and not the surface of it. So sometimes you're left with this awkward situation where you'd think it would be able to see the target part if it was the edge of another part at a different Y position, but it can't since the position of the part is at the centre, rather than the closest point of it, relative to the search part.

    • @EATBADGE
      @EATBADGE 6 місяців тому +1

      You can easily modify it so that the origin is on the surface on the part, just do simple math.

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

      I want to know that "simple" math, when he said about calculate surface i remembe vietnam moments, aint no way soneone calculate so many possible points like volumetric sound

  • @miniamobfighter7271
    @miniamobfighter7271 7 місяців тому +12

    For "While True" loops, instead of having to put a delay at the end of the loop, you can do
    While wait() do
    -- Code here
    end

    • @rfsalt
      @rfsalt 4 місяці тому +2

      thanks dude! saved me 1 line of code-

    • @AntiNuke_
      @AntiNuke_ 4 місяці тому +4

      It's actually more efficient to use task.wait(), because wait is deprecated

    • @xyizsilver
      @xyizsilver Місяць тому

      how DARE you use wait()

    • @boblox_studio_dev
      @boblox_studio_dev 18 днів тому

      putting task.wait inside of while true do is better than putting while task.wait

  • @JamesNJoe
    @JamesNJoe Рік тому +6

    Great tutorial gnomecode! I love seeings these kinds of tutorials. I watch these while waiting for doors part 8. Good stuff.

  • @ryuu6271
    @ryuu6271 9 місяців тому +21

    Whitelist and Blacklist are deprecated, you have to use Include and Exclude respectively, good luck with coding everyone

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

      Yea it's annoying, I think that's very recent because I remember only a few months ago going onto my game and seeing a red underline on all the "Blacklists" so I had to change like 20+ scripts to "Exclude"

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

      @@insertusernamehere8125You can just use the replace world feature to replace everything :/

    • @baconoculto1392
      @baconoculto1392 4 місяці тому +1

      Ty

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

      yoo thank you man i was trying to figure out why it wouldnt work!

    • @poorlymadeproduction
      @poorlymadeproduction Місяць тому

      why do those freaks keep doing that

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

    Thanks man! I'm using this like The Mad Murderer 2 in where the gun has a big line instead of a gradually increasing bullet.

  • @chara_dreemurr4505
    @chara_dreemurr4505 3 місяці тому +1

    With this you can also do the doctor who angel mechanic for a horror game, interesting

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

    hi, thanks for the new amazing video! I'm sure it will come in handy for many!

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

    you can also calculate direction at workspace:Raycast() part using CFrame:LookAt()

  • @IgnatiousRainwater
    @IgnatiousRainwater 3 місяці тому +1

    remember the reason there is no need for ~= nil in the if statement is because (in lower-level languages) the condition syntax secretly has a `identifier == 1` which 1 meaning true saying the identifier does exist. If you use the `NOT` keyword or `!` operator then it's opposite (0). All of this happens behind the language interpreter

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

    i learn more about Raycasting cuz of that video thank you.

  • @Specter109
    @Specter109 7 місяців тому

    thank You So Much For Making This Video, this is very Helpful For Me Because Im Making A Battleship Tower On My Td Game And I had A Small Turret Which I Want It To Shoot if It Detect The Target And I Didn't Know Anything About raycasting until now, thx for making this video

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

    I agree with others, this seems to be a good tutorial! I've heard that Roblox has added "shape-casts" sometime recently, though. I wonder how those work compared to raycasts, which are just drawing a line from a position in a specific direction.

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

    Pretty good video, honestly very useful for paintballing games or whatever, but I need something important, How do I make the animate 2 script compatible with other scripts that load other animations?

  • @--Neptune-
    @--Neptune- Рік тому

    This is literally so helpful thanks

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

    you made this so much more simple

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

    Thank you so much Gnome.

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

    damn bro thank u for creating this i literally wanted this right now lol

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

    Wonder what part 8 of doors tutorials could be?! I was also wondering if you could show me how to make other hiding spots like beds or specifically for my map, an elevator!

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

      a bed hide mechanic would be kinda useless because it’s basically just the locker but with changed animations

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

      elevator would be something like using tweenservice

  • @creepermods4641
    @creepermods4641 6 місяців тому +1

    Even though the title confused me, instead... The title should be *How To Make Line Of Sight* but this is really helpful because i need to make line of sight!

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

    nooo! i wanted to see the ball at the end fall into the void! D:
    great tutorial though! can't wait to see more!

  • @nightlure-SAPPHIRE
    @nightlure-SAPPHIRE Рік тому

    Thanks man I needed to learn this for my entities (rush and ambush)

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

      trust me raycast jumpscares are no easy bro

    • @nightlure-SAPPHIRE
      @nightlure-SAPPHIRE Рік тому

      @@jakejat2 I just tried it and it's is NOT easy. What happened was it only kills the player in a certain range. That range isn't big enough, it's like lookvector. Only if rush's part is facing towards the player. Then it will kill the player

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

      @@nightlure-SAPPHIRE hmm thats seems like a problem with your raycasting script

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

    Can't wait lol, I'm always so confused by Ray casting

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

    I was hoping the ball would turn yellow at the last second haha... anyways
    great informative video! thanks!

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

    you can use the raycast to make Rush's (optionally Ambush's) AI in your Doors tutorial, right?

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

    good video, we need pathfinding tutorial next

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

    Thanks! i might try making AI visibility, with ray cast

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

    Thanks for the epic video! When will we get a doors tutorial? Just saying :)

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

    Could u tell me how to raycast the object to the player?

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

    Yes I love to be early to this GnomeCode video

  • @perac3289
    @perac3289 Рік тому +6

    Thank you gnome for this advice. Just to be clear I've been watching since 1k subs seeing you grow this far in a year is impressive for me. Thank you for always being here for us!

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

      Thanks for sticking around :)

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

      ​@@GnomeCodehey could you continue with your doors tutorials? Maybe ambush or cruzifix

  • @Vi______
    @Vi______ Рік тому +19

    Hey Gnome! I have been watching your videos for a while now, since they are the only ones that actually teach me lol. I wanted to ask you to do a simple Object Oriented Programming guide for roblox studio. Apparently, it's a way to make your code more organized and efficient, some people say it's really important

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

      Yes, we need an OOP series

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

    GnomeCode I love your tutorial videos and I like them can you do a leaderboard

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

    Hey can you make a video on how to make a monster like doors like you made last time but can you make it use raycasting so it kills you when the monster sees you like ambush? Also keep up the great work it helps alot!

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

    WHEN IS THE NEXT GNOMEJAM!!! IM SO EXCITEDDD

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

    Hey Gnome. Would you do a gamenight on christmas?

  • @chakira2822
    @chakira2822 8 місяців тому

    It helped me a lot when making scp 096 :)

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

    Hey, I have a personnel question - what keyboard do you use?

  • @moshietter3206
    @moshietter3206 8 місяців тому

    how exatcly would this work on legs though if you want the legs to move up when its on a higher elevation but not go literally above the waist/core?

  • @danzstuff
    @danzstuff 20 днів тому

    i'm trying to make a web swinging system with raycasts, and i'm kinda stuck on the raycast direction part

  • @1VRRR
    @1VRRR Рік тому

    Quick question.Can you remake your 2d plat-former tutorial.I think your last one is a little outdated.Thank you!

  • @Tucoy.Incredibox.0705
    @Tucoy.Incredibox.0705 Рік тому +3

    I can finally script Eyes!

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

    GnomeCode, can you make a tutorial on how to make a inverse kinematics spider that can move around?

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

    i'm a legend i liked and it turned to 700 woah great vid

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

    now i realise that projectiles just are too complicated for me im happy that i finnally understand cframe and raycasting in a simple but effective way

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

    I remember first starting Roblox Studio and remembering "I'm going to need to learn Ray Cast" and I struggled so much, but thanks to this amazing and short video I fully understand the basics of Ray Cast. I want to say thank you 😁

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

    So going back to AI could put raycasting inside of the killing AI? (Making it so every time the AI see`s you it gives a good chase...)

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

    be careful y'all. app, the blacklist function has been deprecated and replaced with another one called "exclude", which does basically the same

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

    why there's no video How To Destroy Block On Look Roblox Studio

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

    What if i want a range for a ray tho? Like this ray goes to the other side of the planet and if i want to detect something near 50 studs for example i cant do that like that can i? it would be epic if you record and part 2 or Full guide to raycast

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

    Hey GnomeCode! I'm a beginner scripter and currently following your TD series. Of course, I'm adding my own features using what I learned from your tutorials.
    Everything's going well till I try to add a Gun Trail feature. I've tried twice but failed, is there something I'm missing on?

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

      i dont have problems with the gun rail part. i have problems with the distance measuring.

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

      I'm just going to assume that by that you mean you want a trail for the bullet. If you want that, then add a trail in the bullet and set the properties, and you should be good. If you are using a script that makes the bullet through the script, then add something similar to this to the script:
      local trail = Instance.new("trail")
      trail.Parent = bullet
      trail.lifespan = (whatever you want)
      (add some more properties)

  • @probablyjaden
    @probablyjaden 8 місяців тому

    Blacklist and Whitelist are deprecated now, make sure you use Include and Exclude instead!

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

    Useful thank you

  • @YorktownClass
    @YorktownClass 11 місяців тому

    2:48 I thought that an error pops up when you reference 2 parts have the same name that are both located in the workspace.

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

    Blacklist and whitelist have been depreciated and replaced with include and exclude. They work functionally the same though

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

    BROOP FINALLLYYYYY

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

    Thanks, this really helped alot with my understanding of raycasting! Appreciate it, keep it up!

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

    Hiya! I am making a game but I need an NPC to be able to walk on walls - i can only find tutorials on it for the player and I can't figure out what I needed!

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

    when i do the filter thing it says: member 'Blacklist' is deprecated

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

    Could you make a real time strategy tutorial please? I want to make one but don’t know how

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

    Epic tutorial! Could you possibly show how to make something simular to SCP-096?

  • @UnrealFlame
    @UnrealFlame 7 місяців тому

    How can i make a gun using raycasting, can u make a video about it?

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

    i can raycast now thank you

  • @jsfk-mb1yr
    @jsfk-mb1yr Рік тому

    u should make a video about the group copying your games

  • @vogoxmario9380
    @vogoxmario9380 Місяць тому

    bro i was having a mental break down for 2 hours, reached out to 2 forums and ai bots for it to be that for direction you dont use unit and its also reversed...

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

    Thankyou

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

    It's been a month... hope the next video comes out soon!

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

    Hi gnome I wanted to make a tower defense game but the tutorial is now outdated, Can you please remake it?

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

    When I open my script I can't find it it it's separated from workspace

  • @koiiii345
    @koiiii345 18 днів тому

    this tutorial is excellent but does (Params.FilterType = Enum.RaycastFilterType.Blacklist) not work for anyone else

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

    btw im pretty sure roblox removed black list or sum so you gotta use exclude now

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

    You should make a video on how to make a War game!

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

    Nice video

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

    Simple,Straightforward,Yet explains very well
    thank you gnoemcode for this tutorial

  • @cod901
    @cod901 8 місяців тому

    this is helpful, but how to make it detect players?

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

    A bit late but i have qestion to tower defense tutorial. You are showing how to do only one path ubgrades but I wanted to make 2 paths of ubgrades like in BTD5. Is there a way of doing that?

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

      That script would be too advanced, so unless you have someone who knows lua well, it won't be possible.

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

    Tip : you don’t have to cut and paste lines of code, you can just select it and drag it to your desired position

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

      nah, its faster to copy and paste because if you drag it it messes up the format and you have to do extra steps to format the code

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

      Yiu can actually "move" the block of code by holding alt and pressing the arrows too!

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

      @@kennethkline7702 really?!

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

      @@epixerty true but you may have something important in your clipboard

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

      @@fexryourfriend I use both, because youre right here, but i find copy and pasting more convenient most of the times

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

    Nice

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

    Gnome is scary I was looking for a Raycast tutorial (I haven't made a game with Raycasting in a Year) and then this

  • @JachaiStephens
    @JachaiStephens Місяць тому

    Can someone tell me the scripts so i can copy and paste them?

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

    W tutorial!

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

    What's dat studio font :))

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

    Rest in peace red ball you will be missed 😔

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

    Hey Gnomecode, i was thinking if you could maybe do a gnomejam again i would realy like that cause im a begginner developer and i would learn a lot from the gnomejam.

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

    3 more hours to be save of this fire

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

    you are the griffpatch of roblox

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

    When is the next Doors vid?

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

    POV: you see a GnomeCode video from 12 minutes ago AND It's about something that always confused you

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

    when the doors series videos? i miss them :(

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

      I will continue the series in the new year, I'm on Christmas break right now :)

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

    Doom is not done alone

  • @YouAreNotHim754
    @YouAreNotHim754 11 місяців тому

    Blacklist is deprecated now. Is it alright to keep using it?

    • @404-AnimationYT
      @404-AnimationYT 11 місяців тому

      Blacklist was replaced by 'Exclude' I think

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

    hello there can you teach me how to make a game like clash royale in roblox please