i’ve been working on trying to replicate shadows from old console games. i got the positioning done, but i’m stuck on figuring out how to make it rotate depending on what angle or slope it’s on, like shown in this mockup i did
You can try getting the part the player is standing on, and then rotate it according to the part. I don’t know how it would be done with Terrain, but I assume there is a function that would find that as well.
You can cast a ray downwards from the part’s position and if there’s an intersection, you can get the normal of the intersection, which is a vector that is perpendicular to the hit surface, then you can do something like this every frame:
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = {Part}
local result = workspace:Raycast(part.Position, Vector3.new(0, -5, 0), params)
if result then
part.CFrame = CFrame.new(part.Position, part.Position + result.Normal)
end
1 Like
Ah alright. I’ll try this out.