I want to make a creature stand up and im using raycast to make it detect the floor and then change its
height but what actually happens is it moves the creature to the side and multiples this effect the further away from 0,0,0. I don’t really know much on raycasting and I cant find any in depth sources on it so I’m quite stummped.
This is the script:
for i,e in pairs(script.Parent.Supports.WalkingPairs.Number1:GetChildren()) do
local Part = e.Value.Info.LimbHolder.Value
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {script.Parent}
local origin, direction = Part.Position,Part.Position - Vector3.new(0,e.Value.Info.HoldUpVal.Value + 2,0)
local raycastEEResult = workspace:Raycast(origin, direction, raycastParams)
if raycastEEResult ~= nil then
print("ONNN")
e.Value.Info.LimbHolder.Value.Support.HoldSelf.Position = raycastEEResult.Position + Vector3.new(0,e.Value.Info.HoldUpVal.Value,0) --e.Value.Info.LimbHolder.Value.Position + Vector3.new(e.Value.Leg1.LegEnd.Foot.Size.X,0,0)
e.Value.Info.LimbHolder.Value.Support.HoldSelf.MaxForce = 8000000000000
else
e.Value.Info.LimbHolder.Value.Support.HoldSelf.MaxForce = 0
end
Can someone explain whats wrong or what needs fixing
The test creature aka pair of legs is falling over and the direction is always stationary over spawn (workspace.EE.Position = direction is how I’m trying to see where it is).
What did you mean when you said imagine that’s already set for you?
I did try it out and mess with it a few times to try get it to work but the ray just wasn’t changing to the “limb holder” or black cylinder it’s just going to a 0,0,0 but elevated, I don’t know much on ray casting and can’t really 100 percent fabricate an understanding of how direction works or it’s relation to the origin but aren’t I ment to specify for it to be under the origin in my case? And when I said it’s nil I ment even when I put a wall between the direction and origin it way always nil still.