Honestly I'm grateful for your vids that explain what your doing, allows me to not only undestand but to learn new scripts and codes, pls make more when you have the time
Just to ask, is this script an the one you made before for Hit box similar. I have a hard time coding and learning codes, Visual displays help me understand i bit better what the out come should look like and since your last one had that i wanted to know if they were similar in anyway?
I knew about magnitude but never thought of using it for attack/hitbox, definitely great vid and widen my knowledge more, could be used for some special attack
TLDR: Hitbox only detects center of part This sounds like a great idea but upon testing, it seems that the hitbox will only detect the enemy (part) if the center of the enemy (part) is touching the hitbox. Though I doubt it'll be any big deal because Roblox characters are already big enough
This seems to work best when detecting player hitboxes vs. AoE attacks to be more forgiving, rather than for projectile collisions and checking enemy positions I agree shape casting / spatial query hitboxes would be better anywhere else for hit detection
I consider this method of hit registering a very niche one. This would work in any "battleground fighting" game such as "strongest battlegrounds" or games from the same genre. The problem comes with trying to use this same method for other games, such as FPS ones. This method standalone will register a hit even if the victim player is directly below the height of the player, as long as the distance is within the accepted range. Another problem with this system are walls; this method would also register a check even if the victim is at the other side of the wall. As those problems are present, trying to make checks for them would make the code as lengthy as other methods of hit checking, so there wouldn't be any advantage So, for the tldr: This method is good for battleground fighting games, but for a different genre, there would be better options definitively I appreciate your effort for offering the roblox dev community a source of learning, not everyone does what you're doing Keep the good work! :]
Yea, when it comes to hitboxes, there isn't a "one solution fits all" for FPS games, def ray casting, for more highly accurate needs, spatial query, and for a standard, general purpose solution, magnitude.
yea the video I made about my hitbox module, I made the module paid access, and I regret doing that, but I still have it if you absolutely need it. I would suggest making one yourself though since you will understand it a lot better.
You're right, this method works best with defined enemies, but there are other ways to detect collisions in Roblox Studio, like using Region3s or Raycasting.
this is true, but instancing a part requires replication (adds delay) and using a .touched on a part only checks when something interacts with the part after it is spawned, meaning if you spawn a part inside of a player the .touched won't trigger (or at least in my testing it didn't), there is an alternative hitbox method using GetPartBoundsInBox() which I will go over in another video.
@@Tekleed No need to instance the part everytime you do an action, you can just have it be there from the start and only look for .touched during the action, either way these are just a bunch of ways to solve the same problem, obviously you should pick the best one for your case scenario.
@luckyboy5nu This is a decent method, but even still, having the part exist is just not needed. If you absolutely need it to be a box like that. The getpartboundsinbox method is still my preferred way to go. ( I used to do the part method ngl 😅 )
@@Tekleed The problem with the method you suggested in the video is that: 1. You are suggesting that in the script we should search/find the player (which you haven't explained how that would be possible, with this method you'd have to check every frame for a nearby player somehow) 2. Then after that we should take the vector Position of both players (this takes up frame time) 3. Calculate the difference between the positions of both you and the player 4. Validate if it is within range and register the hit While this is a totally valid method, there's just no real reason to do all this for a simple hit check when Roblox already has meticulously optimized methods of this for you to use, that are much more optimized than the method your showing.
1. For finding out positions of players nearby, you can either use octrees, or you can just go through all players in the game, then if they are within a threshold of let's say 100 studs, you can add them to a list to then do the SLIGHTLY more computationally heavy hitbox check. 2 + 3. Doing a magnitude check is one of the cheapest operations you can do. so even doing it multiple times a frame, on multiple players it will hardly use up any resources. On top of all of this relying on Roblox's .Touched function especially for a part, means you would have to rely on the Roblox physics engine to be accurate when doing said hitbox check. I do believe the method I explained in this video is the most efficient way of doing hit detection. but unless their are some sort of performance metrics that can prove me wrong. then I will keep using this ngl.
3:36 are you saying that if a character is within the radius of the magnitude we just need to check the direction because how are getting the enemies position from the parameter?
so they way you would get the enemies position to check against, would be to loop through all the enemies in the game, you can further optimize this by using like octrees or just having a generalized magnitude check first without direction, so instead of checking the whole game, you would just check all enemies with like 100 studs or so.
@@jlboss_ps4751 there isn't really a universal solution for hitboxes, especially for a game like that since it depends on what move you want to use, like an AOE move would work very well with magnitude, but there is probably a better method if you want heavy constraints on the hitbox.
Woudlnt this require the game to iterate over all the enemy players on the game tho? You need to do the check for every possible enemy, In a game that has alot of NPCS or player or even like things you can attack it would mean alot of things to iterate iver and and so in best case time complexity of O(n) and in worst O(n²). I assume this could be prevented with some kind of simplified Spatial check before the magnitude check?
Yea, you could optimize it by doing a broad phase check first by just doing the basic magnitude check of like 100 studs, and since that would be super quick, you can then go onto the narrow phase and do the more complicated magnitude + dot product check.
@Tekleed This method is still great if mixed with other more accurate but power hungry methods like Raycasts. Thank you for showcasing magnitude checks (i would have never thought of using dot product to limit the angle haha!) I will definitely use this as a spatial precheck thing.
I'd like to ask, within the parameters of the call function, what does Alive mean? Because I've plugged this in to a script and I ended up with "Alive isn't a valid member of Workspace "Workspace" ".
@Tekleed Thank you for the response, much appreciated. I really enjoy the content you produce, very informative and it really does help; which is funny because it made me look back to some lessons I actually learned during math class and it kinda gave me a chuckle watching your videos. You have my sub
Performance reasons for sure, it's way quicker for a computer to do the Pythagorean theorem, (which is how the .magnitude property is solved) than to query a region of space using region 3 or anything else.
I know you did NOT just stop the video right before it hit the bottom right corner!! We want justice!
LOL
All the classes I failed at my engineering study are coming back to haunt me in studio
the dvd logo background is quite mesmerizing
its like putting family guy clips on a short except its an educational video
you didn't even need the flashy subtitles and image fr the dvd logo alone is enough to take hold of my low attention span
Lol, I'll take note for next time.
Honestly I'm grateful for your vids that explain what your doing, allows me to not only undestand but to learn new scripts and codes, pls make more when you have the time
Just to ask, is this script an the one you made before for Hit box similar. I have a hard time coding and learning codes, Visual displays help me understand i bit better what the out come should look like and since your last one had that i wanted to know if they were similar in anyway?
I'm glad you are enjoying the content! I try to make it easy to understand. More content is coming soon!
Same idea and methods behind them, my hitbox module one is more sophisticated for sure.
Finally I see someone covering this!! I see so many people using scuffed hitboxes this is great.
I knew about magnitude but never thought of using it for attack/hitbox, definitely great vid and widen my knowledge more, could be used for some special attack
Magnitude Hitboxes? What are you talking about, i came here for the dvd thingy
TLDR: Hitbox only detects center of part
This sounds like a great idea but upon testing, it seems that the hitbox will only detect the enemy (part) if the center of the enemy (part) is touching the hitbox. Though I doubt it'll be any big deal because Roblox characters are already big enough
This seems to work best when detecting player hitboxes vs. AoE attacks to be more forgiving, rather than for projectile collisions and checking enemy positions
I agree shape casting / spatial query hitboxes would be better anywhere else for hit detection
I consider this method of hit registering a very niche one. This would work in any "battleground fighting" game such as "strongest battlegrounds" or games from the same genre. The problem comes with trying to use this same method for other games, such as FPS ones. This method standalone will register a hit even if the victim player is directly below the height of the player, as long as the distance is within the accepted range. Another problem with this system are walls; this method would also register a check even if the victim is at the other side of the wall. As those problems are present, trying to make checks for them would make the code as lengthy as other methods of hit checking, so there wouldn't be any advantage
So, for the tldr: This method is good for battleground fighting games, but for a different genre, there would be better options definitively
I appreciate your effort for offering the roblox dev community a source of learning, not everyone does what you're doing
Keep the good work! :]
Yea, when it comes to hitboxes, there isn't a "one solution fits all" for FPS games, def ray casting, for more highly accurate needs, spatial query, and for a standard, general purpose solution, magnitude.
thank you a lot for this. if I didnt watch this video I wouldn't have realized there was another way to do hitboxes, this is super useful. Thanks
This is awesome!
bro, you don't know how much I needed this. Thx so much
I think your videos are really well put together, wishing you luck
Thank you!
just letting you know, this video gave me a great idea and now ive learned lua’s programming. this hell is your fault
You are so very welcome.
amazing bro learned more in 3 mins than 1 week at school ☠
Life saver keep going man!
Appreciate it!
@@Tekleed just a question I can't find the hitbox module from your previous video inside the discord?
yea the video I made about my hitbox module, I made the module paid access, and I regret doing that, but I still have it if you absolutely need it. I would suggest making one yourself though since you will understand it a lot better.
@@Tekleed all good
Lovely, more hitbox videos, legends say after watching 50 of them I can make perfect hitboxes and people would still complain
using a screensaver as a background is fucking genious
I first saw a video, this video and i realized how useful your videos are so i subscribed...
Awesome, thank you!
@@Tekleed you're welcome, I hope I catch up to you
This sounds hard. I always just made a part that does damage and made some scripts that it spawns infront of the player who clicked
Very epic now my stick doesn't hit people 3 light years away
just call it a spherical hitbox
ngl this is very good
finally good video explaining physics. 🤓
I've always preferred raycast hitboxes
A major problem with this method is that its only applicable if you already defined who/what the enemy is.
This just doesnt seem good for most games.
You're right, this method works best with defined enemies, but there are other ways to detect collisions in Roblox Studio, like using Region3s or Raycasting.
Could also just use a part infront of the player that checks for trigger collisions which is literally designed for this exact problem
this is true, but instancing a part requires replication (adds delay) and using a .touched on a part only checks when something interacts with the part after it is spawned, meaning if you spawn a part inside of a player the .touched won't trigger (or at least in my testing it didn't), there is an alternative hitbox method using GetPartBoundsInBox() which I will go over in another video.
@@Tekleed No need to instance the part everytime you do an action, you can just have it be there from the start and only look for .touched during the action, either way these are just a bunch of ways to solve the same problem, obviously you should pick the best one for your case scenario.
@luckyboy5nu This is a decent method, but even still, having the part exist is just not needed. If you absolutely need it to be a box like that. The getpartboundsinbox method is still my preferred way to go. ( I used to do the part method ngl 😅 )
@@Tekleed The problem with the method you suggested in the video is that:
1. You are suggesting that in the script we should search/find the player (which you haven't explained how that would be possible, with this method you'd have to check every frame for a nearby player somehow)
2. Then after that we should take the vector Position of both players (this takes up frame time)
3. Calculate the difference between the positions of both you and the player
4. Validate if it is within range and register the hit
While this is a totally valid method, there's just no real reason to do all this for a simple hit check when Roblox already has meticulously optimized methods of this for you to use, that are much more optimized than the method your showing.
1. For finding out positions of players nearby, you can either use octrees, or you can just go through all players in the game, then if they are within a threshold of let's say 100 studs, you can add them to a list to then do the SLIGHTLY more computationally heavy hitbox check.
2 + 3. Doing a magnitude check is one of the cheapest operations you can do. so even doing it multiple times a frame, on multiple players it will hardly use up any resources.
On top of all of this relying on Roblox's .Touched function especially for a part, means you would have to rely on the Roblox physics engine to be accurate when doing said hitbox check.
I do believe the method I explained in this video is the most efficient way of doing hit detection. but unless their are some sort of performance metrics that can prove me wrong. then I will keep using this ngl.
underrated asf
3:36 are you saying that if a character is within the radius of the magnitude we just need to check the direction because how are getting the enemies position from the parameter?
so they way you would get the enemies position to check against, would be to loop through all the enemies in the game,
you can further optimize this by using like octrees or just having a generalized magnitude check first without direction, so instead of checking the whole game, you would just check all enemies with like 100 studs or so.
@@Tekleed Oh I see now thank you for the insight, would you also say magnitude checks would be the best choice for games like battlegrounds hitboxes?
@@jlboss_ps4751 there isn't really a universal solution for hitboxes, especially for a game like that since it depends on what move you want to use, like an AOE move would work very well with magnitude, but there is probably a better method if you want heavy constraints on the hitbox.
ADHD VER: magnitude is distance which is sqrt((x1-x2)^2+(y1-y2)^2) thing. If the magnitude is higher than the range of the attack it’s a hit.
What about raycast hitboxes? I feel like they are also good
idk why the creator didnt reply to this comment because i have the same question
@DeltaModelX yeah i also don't know why lol
Do you edit your own videos
Yes
Woudlnt this require the game to iterate over all the enemy players on the game tho? You need to do the check for every possible enemy, In a game that has alot of NPCS or player or even like things you can attack it would mean alot of things to iterate iver and and so in best case time complexity of O(n) and in worst O(n²). I assume this could be prevented with some kind of simplified Spatial check before the magnitude check?
Yea, you could optimize it by doing a broad phase check first by just doing the basic magnitude check of like 100 studs, and since that would be super quick, you can then go onto the narrow phase and do the more complicated magnitude + dot product check.
@Tekleed This method is still great if mixed with other more accurate but power hungry methods like Raycasts. Thank you for showcasing magnitude checks (i would have never thought of using dot product to limit the angle haha!) I will definitely use this as a spatial precheck thing.
I'd like to ask, within the parameters of the call function, what does Alive mean? Because I've plugged this in to a script and I ended up with "Alive isn't a valid member of Workspace "Workspace" ".
Alive is a folder inside if the workspace will just contain the players / enemies that are alive
@Tekleed Thank you for the response, much appreciated. I really enjoy the content you produce, very informative and it really does help; which is funny because it made me look back to some lessons I actually learned during math class and it kinda gave me a chuckle watching your videos. You have my sub
@@AethernityArts Lol glad I could help in some way, and thank you gang.
what did i just watch
If I may ask, what advantages would this kind of hitbox method give over the usual, such as Region3, Raycast, and Touched?
Performance reasons for sure, it's way quicker for a computer to do the Pythagorean theorem, (which is how the .magnitude property is solved) than to query a region of space using region 3 or anything else.
@@Tekleed I see. Thanks for the insight!
@@OmegaDesu no problemo
Why not use a hitbox? Is there any major benefit? To me, using a hitbox is far simpler
Performance reasons.
hi can u make Tool Destruction Or Like Skill Destruction
What do you mean by this exactly?
Is this really performant? I think raycasts would do way better for PvE
This might be more of a Tower Defense thing.
This all depends on what you want to do. There isn't a "one solution fits all kind of thing".
theekleed moment hier
is there a reason to do this over a spacial query
It takes fewer resources to do as compared to a query.
I still dont understand how this works :(
I can try helping more by giving you an example place to look at, if it will help.
@@Tekleed that would be fantastic actually
@@letheryxd4846 Add me on discord and I'll whip up something really quickly
I actually made it a downloadable place, here is the link to it
www.roblox.com/games/84285695203255/Magnitude-Hitbox-Demo
@@Tekleed sorry I didnt see this, thanks! Lets see if im up to the math stuff in this
Praise Jesus!