I want to make FloorMaterial in Lua, because the inbuilt Humanoid property of the same name is set by both the server and player of that character. If I have local particle parts and the client is on top of one they will disagree, StateChange will event causing characterSounds to spam… a lot.
How do I do emulate this in Lua so it’s just the client or just the server best? It is not a mere ray down from the center of the HRP. I want to know what it is, and how to you would recommend approaching it.
FloorMaterial is, in fact, a downward raycast from the HumanoidRootPart. Same goes with virtually any other mechanism that requires knowing what’s under the character (such as if a part is there, this will be conveyed to the Humanoid object to move above it - Humanoids stand on things via raycasting).
Raycasting’s expense primarily comes from the ray’s length. The distance from the HumanoidRootPart to the ground is just 2.5 studs, which is not long at all. You can fire a raycast every frame 2.5-3 studs downward, in fact hundreds of them, without any significant expense or performance hit.
Adding to this, you don’t even need to do the full 2.5 - 3 studs, just what is underneath the legs of the humanoid. However at this point, the performance difference is probably quite negligible.
As far as doing it on the client or server, I recommend doing it on the client for players within 50 - 100 studs, depending on the volume dynamics of your game.
It is not a downward raycast, and this is kind of what makes it special for grazing fall damage:
I’m assuming it does eight raycasts, for each edge of a scan box below the HRP.
Dimensions varying based on character proportions, in average case basically making a box of rays the size of the HRP translated down a few studs
It is a downward raycast. This has been clarified by engineers before. What’s your citation for suggesting it’s not? Here are mine for saying it is: two engineer replies talking about Humanoids performing downwards raycasts for Humanoid logic. Something you could’ve searched for as well.
FloorMaterial is no exception. It can’t determine that property off a box cast to the floor unless it’s working by some majority which I strongly doubt. That being said, you were looking to emulate how the property works and this is how you can.
Fall damage failures are implementation-rooted and I’m not too sure how that’s relevant.
You said raycast, singular. It is raycasts yes, thank you for the citations, you may have been saying raycast as in the general act or system for doing so, but such intention remains unclear to me; assuming you meant a single ray down which it is obviously not as with my image proving so.
So multiple raycasts, creating a bounding box, is what I will do. If you can clarify or advice a different means of using a finite amount of rays to secure the floorMaterial correctly for all possible alignments of the geometry respective to the HRP please, go ahead. This is all I can contrive however.