Hello, I am making a combat system for a game. I am currently trying to make the downslam attack as a combo ender. Everything is fine with the downslam besides the ground detection. I am trying to make it detect the ground so I could make a rock circle effect. Theres a problem though. The ground detection is SUPER innacurate and sometimes it doesnt even work. Any ideas how to fix this?
Script:
local rootPart = v.Parent.HumanoidRootPart -- v.Parent is the enemy's char.
local rootPartHeight = v.Parent.Humanoid.HipHeight + rootPart.Size.Y / 2; -- calculate height of the root part from the bottom of the character
local rayParams = RaycastParams.new()
rayParams.FilterDescendantsInstances = {v.Parent,player.Character}
rayParams.FilterType = Enum.RaycastFilterType.Blacklist
repeat
local raycast = workspace:Raycast(rootPart.Position, Vector3.new(0, -9000, 0), rayParams)
local distance;
if raycast then
distance = (rootPart.Position - raycast.Position).Magnitude
end
wait()
until distance and distance <= rootPartHeight
print("LANDED")
Example video: problem with landing detection
thanks in advance!