Learn Raycasting in 7 minutes - Advanced Roblox Scripting
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
Пікірлер: 213
just realized with this i can make pizza tower's "dont make a sound" mechanic. this is going to be so cool
@pe_w
11 ай бұрын
Can you explain this more if sounds like an interesting concept
@anotherdeadchannel
10 ай бұрын
@@pe_wI think depending on the distance they won't make a sound
@RammansPizzas
9 ай бұрын
@@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_dood
2 ай бұрын
You don't need raycasting to do that. You can just use .magnitude to see the distance between the positions of their root parts.
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!
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!
Whitelist and Blacklist are deprecated, you have to use Include and Exclude respectively, good luck with coding everyone
@insertusernamehere8125
6 ай бұрын
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
6 ай бұрын
@@insertusernamehere8125You can just use the replace world feature to replace everything :/
@baconoculto1392
4 ай бұрын
Ty
@VroomVroomCar221
Ай бұрын
yoo thank you man i was trying to figure out why it wouldnt work!
@poorlymadeproduction
16 күн бұрын
why do those freaks keep doing that
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.
Thanks! A lot more simple than i thought! You are very underrated.
Thank you. I have been really confused with raycasting. Now I fully understand how it works. Thanks GnomeCode!
thank you so much for this man. i cant describe in words how thankful i am
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
4 ай бұрын
thanks dude! saved me 1 line of code-
@AntiNuke_
3 ай бұрын
It's actually more efficient to use task.wait(), because wait is deprecated
@xyizsilver
Ай бұрын
how DARE you use wait()
Thank you most tutorials are outdated or confusing this helped alot
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
6 ай бұрын
You can easily modify it so that the origin is on the surface on the part, just do simple math.
@Miguel_Angel51
3 ай бұрын
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
The perfect video! Haven't watch it whole yet, but surely it will be good! :)
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.
Great tutorial gnomecode! I love seeings these kinds of tutorials. I watch these while waiting for doors part 8. Good stuff.
i learn more about Raycasting cuz of that video thank you.
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
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.
This is literally so helpful thanks
nooo! i wanted to see the ball at the end fall into the void! D: great tutorial though! can't wait to see more!
hi, thanks for the new amazing video! I'm sure it will come in handy for many!
damn bro thank u for creating this i literally wanted this right now lol
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
you can also calculate direction at workspace:Raycast() part using CFrame:LookAt()
you made this so much more simple
I was hoping the ball would turn yellow at the last second haha... anyways great informative video! thanks!
Thanks man I needed to learn this for my entities (rush and ambush)
@jakejat2706
Жыл бұрын
trust me raycast jumpscares are no easy bro
@nightlure-SAPPHIRE
Жыл бұрын
@@jakejat2706 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
@jakejat2706
Жыл бұрын
@@nightlure-SAPPHIRE hmm thats seems like a problem with your raycasting script
Can't wait lol, I'm always so confused by Ray casting
Thank you so much Gnome.
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!
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?
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
Жыл бұрын
Thanks for sticking around :)
@Cowboy_Hat202
Жыл бұрын
@@GnomeCodehey could you continue with your doors tutorials? Maybe ambush or cruzifix
With this you can also do the doctor who angel mechanic for a horror game, interesting
good video, we need pathfinding tutorial next
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
Жыл бұрын
a bed hide mechanic would be kinda useless because it’s basically just the locker but with changed animations
@vrfrenzy8451
Жыл бұрын
elevator would be something like using tweenservice
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
Жыл бұрын
Yes, we need an OOP series
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
BROOP FINALLLYYYYY
Thanks for the epic video! When will we get a doors tutorial? Just saying :)
It helped me a lot when making scp 096 :)
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!
Yes I love to be early to this GnomeCode video
WHEN IS THE NEXT GNOMEJAM!!! IM SO EXCITEDDD
W tutorial!
GnomeCode I love your tutorial videos and I like them can you do a leaderboard
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 😁
Thanks! i might try making AI visibility, with ray cast
i'm a legend i liked and it turned to 700 woah great vid
you can use the raycast to make Rush's (optionally Ambush's) AI in your Doors tutorial, right?
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?
Useful thank you
I can finally script Eyes!
Epic tutorial! Could you possibly show how to make something simular to SCP-096?
Gnome is scary I was looking for a Raycast tutorial (I haven't made a game with Raycasting in a Year) and then this
Blacklist and Whitelist are deprecated now, make sure you use Include and Exclude instead!
Hey Gnome. Would you do a gamenight on christmas?
Hey, I have a personnel question - what keyboard do you use?
Quick question.Can you remake your 2d plat-former tutorial.I think your last one is a little outdated.Thank you!
Thanks, this really helped alot with my understanding of raycasting! Appreciate it, keep it up!
GnomeCode, can you make a tutorial on how to make a inverse kinematics spider that can move around?
It's been a month... hope the next video comes out soon!
i can raycast now thank you
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
Жыл бұрын
i dont have problems with the gun rail part. i have problems with the distance measuring.
@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)
Thankyou
You should make a video on how to make a War game!
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
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.
u should make a video about the group copying your games
this is helpful, but how to make it detect players?
Blacklist and whitelist have been depreciated and replaced with include and exclude. They work functionally the same though
Nice video
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.
be careful y'all. app, the blacklist function has been deprecated and replaced with another one called "exclude", which does basically the same
why there's no video How To Destroy Block On Look Roblox Studio
For any new people, Roblox removed Enum.RaycastFilterType.Blacklist and Enum.RaycastFilterType.Whitelist: Now Blacklist is Enum.RaycastFilterType.Exclude And Whitelist is Enum.RaycastFilterType.Include Hope this helps :)
@Freddy_711
11 ай бұрын
Thanks for your help!
@ben252
11 ай бұрын
damn and i thought i did something wrong, thanks.
@titanwhy4284
10 ай бұрын
Thank you
@programmedchip
10 ай бұрын
Thanks!
POV: you see a GnomeCode video from 12 minutes ago AND It's about something that always confused you
Could u tell me how to raycast the object to the player?
3 more hours to be save of this fire
Could you make a real time strategy tutorial please? I want to make one but don’t know how
btw im pretty sure roblox removed black list or sum so you gotta use exclude now
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!
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
Жыл бұрын
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
Жыл бұрын
Yiu can actually "move" the block of code by holding alt and pressing the arrows too!
@fexryourfriend
Жыл бұрын
@@kennethkline7702 really?!
@fexryourfriend
Жыл бұрын
@@epixerty true but you may have something important in your clipboard
@epixerty
Жыл бұрын
@@fexryourfriend I use both, because youre right here, but i find copy and pasting more convenient most of the times
Simple,Straightforward,Yet explains very well thank you gnoemcode for this tutorial
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...
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...)
Nice
Rest in peace red ball you will be missed 😔
you are the griffpatch of roblox
when i do the filter thing it says: member 'Blacklist' is deprecated
What's dat studio font :))
How can i make a gun using raycasting, can u make a video about it?
Hi gnome I wanted to make a tower defense game but the tutorial is now outdated, Can you please remake it?
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
Жыл бұрын
That script would be too advanced, so unless you have someone who knows lua well, it won't be possible.
Hey GnomeCode makes GUI boss life counter system
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 KZread to help me!
When I open my script I can't find it it it's separated from workspace
Hello GnomeCode can't you make a tutorial how to create pet simulator game this would be interesting !
Now either, I don't know anything about programming (which is not true I know LUA, HTML 5, Python, not going to bother listing anything else because it doesn't aid my point. ) Or most of these tutorials describing shapecasts and raycasts are all so convoluted, this one is among them but at least I could grasp some of the information. I know what a raycast and a shapecast is, I know what their use cases are. but knowing when and how they are applied to a script is never shown in one of these videos, or they do and its usually within the heaps of talking people do in these tutorials. Goes through one ear out the other. If I get a comment trying to explain what a raycast or shapecast is/its use cases just like these tutorials do, I might outright ignore it unless you manage to give me a more in-depth view on it. Because your viewing me from the perspective of someone who does not know how to program, does not know how to reference from ROBLOX's API. Both of which I do know how to do, but unfortunately, reading roblox's api reference did not give me a clear understanding of how this works; which is a shame because usually to does. so currently, I know that I can blacklist/whitelist objects, then specify what it is I'm blacklisting/whitelisting. Cool, that works, understood; quite handy! raycast result returns as it states, the result of a created raycast; which I can use in my script. BAM context on not just its use case but WHERE it's applied to my script; other tutorials don't do this or they take far to long and do to much talking to get to this point; which, I described in terms far easier to understand in 3 sentences. This is why I stook with this tutorial. Let me describe my issue and I don't have access to ROBLOX forums so don't ask me to go there. Say I want to do as shown above, to get direction for CF ( CFrame ) I would compare a - b as done here. But what if what I'm comparing isn't a part in workspace for A? and my target B being a player model? Let me show off what I tried to do so that what I mentioned above becomes clearer, I have a part which is non-can collided in a FOLDER with my script within its own folder ELSEWHERE. This part is a zone, its invisible, but can be touched and quarried, My script is trying to look in pairs and it represents each part by " v " with its distinction being its name, So, I have a zone called " desert ", and another zone called " grasslands ": both are in the same music zone folder with only their names to make them unique. My script plays music when a player enters a zone, each song is named exactly to their zone counterparts so that the script can pick a song and match it according to a touched-zone's name. Neat, compact, butttttt this doesn't work. Why? Because the last method I utilized, used region3, which is depreciated and trust me I looked, there are some sources claiming it isn't but that's simply not true. So I started using shapecasts, and for the likes of me, I just don't know how to use them. I mean, I know the bare minimum, and I'm hoping watching this video on RAYcasts will allow be to at least understand the filtering which seems to be used for both shape casts and ray casts. And hopefully draw a line between the two and actually have a solid understanding of it. I'm gonna rewrite my entire code, including what I've learned from this video and what little I can learn from shape casts, by the way, don't look those up unless your willing to dig, youtubers don't know how to explain shapecasts well enough for application on your own; they just tell you what it does and how it can be used. And I think they do that because they think "casting shapes" is complicated, thus they can get away with taking more views from people: Even though I just described what it is and does in two words, casting, shapes.
@Nathan-hl1dm
6 ай бұрын
Start by taking the stick out of your ass and get to the point of your 500 page pretentious comment. If you are not wishing for a reply, which you mention you don't in: "...I might outright ignore it..." because you are afraid of someone misrepresenting you under your fragile ego, maybe do not write a comment and just keep it to yourself. To answer your question anyways: "What if what I'm comparing isn't a part in workspace for A? and my target B being a player model?" The same thing still applies: -Get the world position of point A, which is not a part in the workspace. -Get the world position of point B, which is the target, like a player's character model. You can use the CFrame of the character's root part (usually HumanoidRootPart) to get the position. -Calculate the direction vector by subtracting the position of point A from point B. You mentioned an extremely important flaw though: you have a part which is nonCancollide. Rays do not interact with nonCancollide parts, so your method of making music zones with raycast will not work in its current state. The way you intend on creating music zones seems very impractical and it'd be much better to just use a simple Part.Touched script on a region defined by a giant cancollidefalse block. Why this wasn't your initial idea? You tell me.
When is the next Doors vid?
Doom is not done alone
You did a better explanation in your TD series