So, I’m making a destiny inspired game and I’m trying to make the enemies but I’m having an issue. The enemy tries jumping up the side of the stairs instead of going up them.
code:
-- Settings --
local Size = 4 -- Character size. will break if not set correctly
local GiveUpTime = 5 -- Time it takes for the character to give up a path.
local Radius = 25 -- wander radius
local pathargs = {["AgentHeight"] = 5, ["AgentRadius"] = 4}
local humanoid = script.Parent:FindFirstChildWhichIsA("Humanoid")
local pfs = game:GetService("PathfindingService")
local died = false
function Raycast(PointA,PointB,Params)
table.insert(Params,script.Parent)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = Params
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.IgnoreWater = true
local raycastResult = workspace:Raycast(PointA, PointB, raycastParams)
if raycastResult then
return raycastResult
else
return false
end
end
function PlaceWayPoint(Pos,Color)
local part = Instance.new("Part")
part.Color = Color
part.Shape = Enum.PartType.Ball
part.Material = Enum.Material.Neon
part.Size = Vector3.new(1,1,1)
part.Position = Pos
part.Anchored = true
part.CanCollide = false
part.Parent = workspace
local Attachment = Instance.new("Attachment",part)
return part
end
while true do
wait(math.random(4,5))
local path = pfs:CreatePath(pathargs)
local Pos = nil
local RayPos = script.Parent.HumanoidRootPart.Position + Vector3.new(math.random(-Radius,Radius),0,math.random(-Radius,Radius))
local cast = Raycast(RayPos + Vector3.new(0,50,0),Vector3.new(0,-75,0),{})
if cast then
Pos = cast.Position + Vector3.new(0,1,0)
else
Pos = Vector3.new(math.random(-Radius,Radius),0,math.random(-Radius,Radius))
end
path:ComputeAsync(script.Parent.HumanoidRootPart.Position, Pos)
local waypoints = path:GetWaypoints()
if #waypoints > 0 then
for i = 1, #waypoints do
humanoid:MoveTo(waypoints[i].Position)
local counter = 0
local Part = PlaceWayPoint(waypoints[i].Position,Color3.new(0, 0.666667, 0))
repeat wait(0.1)
--if path.Action == Enum.PathWaypointAction.Jump then
--humanoid.Jump = true
--end
counter += 0.1
until (waypoints[i].Position - script.Parent.HumanoidRootPart.Position).Magnitude <= Size or counter >= GiveUpTime
Part:Destroy()
end
end
end
also does anyone know how to get him to jump across gaps?
also image of said stairs