Aligning floor aura to angle of terrain

1st + second is what i want 3th is what i have

i welded a white cirle (floor aura) to the HumanoidRootPart i wanted to make it follow the angle of the terrain so when standing on angle terrain it sort of looks flush to the terrain

also when the player jumps i want the circle to stay on the terrain and not jump up with the player

i was thinking of doing a raycast and checking the angle of the part/ terrain but that doesnt solve the jumping

is there a way to make it with constraints ? like a ballsocket for the angle and sort ?
cause u have no clue
thx

I don’t recommend welding the aura part to the HumanoidRootPart. A raycast also gives the intersection position, not just the normal. So you can use raycastResult.Position as the position of the aura part and raycastResult.Normal for the rotation. If it’s rotated in the wrong direction, change the order of the vectors in the cross product.

local isApproximatelyHorizontalSurface = 1 - raycastResult.Normal.Y <= 1e-4
local newAuraRotationCFrame = if isApproximatelyHorizontalSurface  then CFrame.identity else CFrame.fromAxisAngle(raycastResult.Normal:Cross(Vector3.yAxis).Unit, math.acos(raycastResult.Normal.Y))
local newAuraCFrame = newAuraRotationCFrame + raycastResult.Position
1 Like

thanks works like a charm prob gonna make it smooth a bit more so its doesn’t do angle more that 65 degrees and jiggles so only change angles every 5 degrees or so

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.