Learn Raycasting in 7 minutes - Advanced Roblox Scripting

Поделиться
HTML-код
  • Опубликовано: 7 авг 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

Комментарии • 229

  • @godssilliestsoldier249
    @godssilliestsoldier249 Год назад +50

    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 Год назад

      Can you explain this more if sounds like an interesting concept

    • @anotherdeadchannel
      @anotherdeadchannel Год назад +2

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

    • @RammansPizzas
      @RammansPizzas Год назад +7

      ​@@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 5 месяцев назад +6

      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 Год назад +6

    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 Год назад +4

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

  • @miniamobfighter7271
    @miniamobfighter7271 9 месяцев назад +14

    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

    • @AntiNuke_
      @AntiNuke_ 6 месяцев назад +5

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

    • @boblox_studio_dev
      @boblox_studio_dev 2 месяца назад

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

  • @workindad
    @workindad Год назад +12

    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.

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

  • @ryuu6271
    @ryuu6271 11 месяцев назад +26

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

    • @insertusernamehere8125
      @insertusernamehere8125 9 месяцев назад +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 8 месяцев назад

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

    • @baconoculto1392
      @baconoculto1392 6 месяцев назад +1

      Ty

    • @VroomVroomCar221
      @VroomVroomCar221 3 месяца назад +1

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

    • @poorlymadeproduction
      @poorlymadeproduction 3 месяца назад

      why do those freaks keep doing that

  • @mediocrecontent9876
    @mediocrecontent9876 Год назад

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

  • @JamesNJoe
    @JamesNJoe Год назад +7

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

  • @dr.albitros4242
    @dr.albitros4242 Год назад +1

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

  • @Snory99
    @Snory99 Год назад

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

  • @BloxyBud74
    @BloxyBud74 4 месяца назад

    Thank you most tutorials are outdated or confusing this helped alot

  • @GreatRamilYT
    @GreatRamilYT Год назад +1

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

  • @Specter109
    @Specter109 9 месяцев назад

    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

  • @reggie9k
    @reggie9k Год назад

    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.

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

  • @Yeilding_HD
    @Yeilding_HD Год назад

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

  • @--Neptune-
    @--Neptune- Год назад

    This is literally so helpful thanks

  • @sodiumchloride8886
    @sodiumchloride8886 Год назад

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

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

  • @reduvicemaster
    @reduvicemaster Год назад +1

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

  • @stinkyra__.t
    @stinkyra__.t Год назад

    Thank you so much Gnome.

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

  • @masonbuk9092
    @masonbuk9092 Год назад

    you made this so much more simple

  • @SirMarny
    @SirMarny Год назад +1

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

  • @creepermods4641
    @creepermods4641 8 месяцев назад +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!

  • @IgnatiousRainwater
    @IgnatiousRainwater 5 месяцев назад +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

  • @block_in_animating
    @block_in_animating Год назад

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

  • @mojitta
    @mojitta Год назад

    good video, we need pathfinding tutorial next

  • @chara_dreemurr4505
    @chara_dreemurr4505 5 месяцев назад +1

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

  • @mmben1368
    @mmben1368 Год назад

    WHEN IS THE NEXT GNOMEJAM!!! IM SO EXCITEDDD

  • @brainlessbrain7834
    @brainlessbrain7834 Год назад

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

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

  • @MeshsStuff
    @MeshsStuff 5 дней назад

    I can make my horror game more realistic now! Thank you! :D

  • @Vi______
    @Vi______ Год назад +20

    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

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

  • @ert5419
    @ert5419 Год назад

    Useful thank you

  • @OfficialRBBBuildMode
    @OfficialRBBBuildMode Год назад +1

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

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

  • @chakira2822
    @chakira2822 10 месяцев назад

    It helped me a lot when making scp 096 :)

  • @HamsterGamin0
    @HamsterGamin0 8 месяцев назад

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

  • @doseofducks6093
    @doseofducks6093 Год назад

    BROOP FINALLLYYYYY

  • @Pyr0Blox1
    @Pyr0Blox1 Год назад

    Yes I love to be early to this GnomeCode video

  • @killa5963
    @killa5963 Год назад +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 8 месяцев назад +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 6 месяцев назад

      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

  • @투코이
    @투코이 Год назад +3

    I can finally script Eyes!

  • @vestisdead
    @vestisdead Год назад +1

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

  • @Kai29FR_
    @Kai29FR_ Год назад

    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 😁

  • @Sv1x182
    @Sv1x182 Год назад +1

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

  • @Paper_Machete910
    @Paper_Machete910 Год назад

    Nice video

  • @TheyAreGettingCloser
    @TheyAreGettingCloser Год назад

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

  • @lennyface987
    @lennyface987 Год назад +1

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

  • @pogrobloxgaming2436
    @pogrobloxgaming2436 8 месяцев назад

    i can raycast now thank you

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

    • @nightlure-SAPPHIRE
      @nightlure-SAPPHIRE День назад

      learned a while ago how to properly use it, and now I can use raycast

  • @thecatsgato5283
    @thecatsgato5283 Год назад

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

  • @moshietter3206
    @moshietter3206 10 месяцев назад

    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?

  • @HauntedBlox
    @HauntedBlox Год назад

    Thankyou

  • @templars44
    @templars44 Год назад

    Hey Gnome. Would you do a gamenight on christmas?

  • @teenageapple3788
    @teenageapple3788 17 дней назад

    With some more knowledge of what I wanna do. I could probably make a vehicle “antigravity” system. Like in Mario Kart 8. When the car is stopped upside down it doesn’t fall off!

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

  • @cahwardev9804
    @cahwardev9804 Год назад

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

  • @danzstuff
    @danzstuff 2 месяца назад

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

  • @sillygoober368
    @sillygoober368 Год назад

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

  • @Gauge12
    @Gauge12 11 месяцев назад

    W tutorial!

  • @1VRRR
    @1VRRR Год назад

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

  • @hunivox
    @hunivox 6 месяцев назад +1

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

  • @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...)

  • @GodrickTheGoIden
    @GodrickTheGoIden 8 месяцев назад

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

  • @berkecan5890
    @berkecan5890 4 месяца назад

    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

  • @jsfk-mb1yr
    @jsfk-mb1yr Год назад

    u should make a video about the group copying your games

  • @gimbus8493
    @gimbus8493 Год назад

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

  • @hazzardreal
    @hazzardreal 6 месяцев назад

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

  • @studiosblox
    @studiosblox 11 месяцев назад +1

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

  • @uru4123
    @uru4123 Год назад

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

  • @NotRynch
    @NotRynch Год назад

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

  • @krabtato
    @krabtato Год назад +1

    Nice

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

  • @OutplayerR
    @OutplayerR 26 дней назад

    Instead of 'Blacklist', use Exclude, As Blacklist is now depricated.

  • @UnrealFlame
    @UnrealFlame 9 месяцев назад

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

  • @alejandrorivera9694
    @alejandrorivera9694 Год назад

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

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

  • @YorktownClass
    @YorktownClass Год назад

    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.

  • @THANUSNUS
    @THANUSNUS 8 месяцев назад

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

  • @lorlema7404
    @lorlema7404 Год назад

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

  • @320linkerbaan24
    @320linkerbaan24 13 часов назад

    for what is the minus at direction 2:30

  • @panned_noob
    @panned_noob Год назад

    you are the griffpatch of roblox

  • @vogoxmario9380
    @vogoxmario9380 3 месяца назад

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

  • @XYWZExtreme
    @XYWZExtreme Год назад

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

  • @cod901
    @cod901 10 месяцев назад

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

  • @Coolcatzz2323
    @Coolcatzz2323 Год назад

    3 more hours to be save of this fire

  • @JoshieBoy_
    @JoshieBoy_ Год назад

    What's dat studio font :))

  • @Sp23419
    @Sp23419 Год назад

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

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

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

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

  • @kryptonnslaxx6378
    @kryptonnslaxx6378 Месяц назад

    how to make it transparent????????????

  • @MadnessNull
    @MadnessNull Год назад

    Rest in peace red ball you will be missed 😔

  • @probablyjaden
    @probablyjaden 10 месяцев назад

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

  • @TheAtomPrince
    @TheAtomPrince Год назад

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

  • @MaxLeft
    @MaxLeft Год назад

    Day 2 on asking: Can you please show how to make a pokemon game? I came up with my own pokemon, but I don't understand how to make games.. I don't understand the Scripting well so that's why I use RUclips to help me!

  • @JachaiStephens
    @JachaiStephens 3 месяца назад

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