#Find if player is on slope
56 messages · Page 1 of 1 (latest)
you could raycast from your character to below the character and then check its normal by the RaycastResult.Normal
Does that work for terrain?
the normal gives you a vector which says which direction the slope is facing
then you can just check its y component and done
yes
local rayResult = workspace:Raycast(humanoidRootPart.Position,humanoidRootPart.Position - Vector3.new(0,10,0) - humanoidRootPart.Position,params)
raycasting works for terrain as well i think so
why -?
wdym why
To draw it from the player's position
humanoidRootPart.Position - Vector3.new(0,10,0) - humanoidRootPart.Position is the only time ive ever gotten a raycast to cast below a player which is weird
you can just do humanoidRootPart.Position - Vector3.new(0, 2000, 0)
How come that works?
your code subtracts your players position, then subracts it by 10, and then subtracts it again by your players position
you can just subtract it by a big arbitrary value like 2000
Why do you need to do that to cast it from the player?
so that we get a ray pointing downwards towards 2000
ah you want the slope if the player is touching it right?
yes
and how would i cast it at their feet since it casts at their torso right now
in the RaycastParams add the whole character to the FilterInstanceDecendants
aka { character }
added that
try
params.FilterDescendantsInstances = {player.Character}
params.FilterType = Enum.RaycastFilterType.Blacklist```
the filter type is by default blacklist so you dont have to add that
oh cool lemme delete thst line
how far down would I want to raycast for jusut below the feet or should i just do trial and error til i get it
oh wait i realised youre casting from your rootpart
just get the character's bounding box by :GetBoundingBox() and then half it (/2) and then subtract it from the rootpart, and then subtract it by 0.5 or 1
lemme give that a try
local rayResult = workspace:Raycast(humanoidRootPart.Position,player.Character:GetBoundingBox().Position / 2 - Vector3.new(0,1,0),params)
bounding box is a position so you can remove the .Position
It says its a cframe
ohhh wait i just realized
dont divide it by 2
also dont remove .Position then
wait
instead of get bounding box
use :GetExtentsSize()
Instead of boundingbox?
yes