generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Pathfinding monsters keep getting stuck.....

Previous Thread :: Next Thread 
axelvts is not online. axelvts
Joined: 27 Apr 2008
Total Posts: 3029
28 Sep 2014 06:54 AM
Is there any way to add a script to the workspace make any humanoid named "Monster" spin around so that they're un stuck?
Report Abuse
axelvts is not online. axelvts
Joined: 27 Apr 2008
Total Posts: 3029
28 Sep 2014 07:29 AM
_-_
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
28 Sep 2014 07:30 AM
You could do like

monster.Torso.CFrame = CFrame.new(monster.Torso.Position + Vector3.new(0, 1, 0))
Report Abuse
PlaceRebuilder is not online. PlaceRebuilder
Joined: 29 Apr 2008
Total Posts: 1056
28 Sep 2014 07:38 AM
Simply make them walk at random if they don't find a path.
Like,
humanoid.WalkToPoint = torso.Position + Vector3.new(math.random(-10,10),0,math.random(-10,10))
You can enhance this by making them not walk into a wall again, using rays checking their path. If it hits a wall, simply walk to the hitpoint - 2*direction.unit (hope this makes sense)

The reason they can't find path is because they are too close to a wall in most cases.
Report Abuse
axelvts is not online. axelvts
Joined: 27 Apr 2008
Total Posts: 3029
28 Sep 2014 07:42 AM
Okay, so where do I have to put this at in here?
Scryppii:

local sp = script.Parent
local newCharacter = sp:Clone()
newCharacter.Parent = game.ServerStorage
wait(0.5)
pathFind = game:GetService("PathfindingService")
local humanoid = sp:WaitForChild("Humanoid")
local torso = sp:WaitForChild("Torso")
local target = sp:WaitForChild("Target")
local location = sp:WaitForChild("Location")

local sp = script.Parent
local humanoid = sp:WaitForChild("Humanoid")
local toolNone = script:FindFirstChild("toolnone")
local toolNoneAnim = toolNone:FindFirstChild("ToolNoneAnim")

local a = Vector3.new(100,5,-100)
local b = Vector3.new(75,5,-200)
local debounce = true
local debounce2 = false
local toolNoning = humanoid:LoadAnimation(toolNoneAnim)
local list = game.Players:GetChildren()
local loco = 100000

sp.PrimaryPart = sp:WaitForChild("Head")


if target.Value then
local targetTorso = target.Value:FindFirstChild("Torso")
end

function attack(hit)
if hit and hit.Parent then
local enemy = hit.Parent:FindFirstChild("Humanoid")
if enemy then
if enemy:IsA("Humanoid") and hit.Parent.Name ~= sp.Name then
debounce = true
while debounce do
toolNoning:Play()
wait(1)
torso.TouchEnded:connect(function(hit2)
if hit2 == hit then
debounce = false
end
end)
end
end
else
if hit.CanCollide then
humanoid.Jump = true
end
end
end
end

function findPlayers()
list = game.Players:GetChildren()
for i=1,#list do
if list[i] and list[i]:IsA("Player") then
local found = list[i].Character:FindFirstChild("Humanoid")
if found and found.Health>0 then
local loc = (torso.Position - list[i].Character.Torso.Position).magnitude
if loc < loco then
loco = loc
target.Value = list[i].Character
end
end
end
end
end


while humanoid.Health > 0 do
target = sp:WaitForChild("Target")
location = sp:WaitForChild("Location")
findPlayers()
if target.Value then
targetTorso = target.Value:FindFirstChild("Torso")
if targetTorso then
path = pathFind:ComputeRawPathAsync(torso.Position,targetTorso.Position,15)
points = path:GetPointCoordinates()
if #points <10 or #points == 10 then
mx = #points
l = true
else
mx = 10
l = false
end
for i = 1,mx/2 do
wait(0.25)
humanoid:MoveTo(points[i*2])
if i == mx/2 and l then
humanoid:MoveTo(targetTorso.Position,targetTorso)
end
end
end
else
path = pathFind:ComputeRawPathAsync(torso.Position,location.Value,15)
points = path:GetPointCoordinates()
if #points <10 then
mx = #points
else
mx = 10
end
for i = 1,mx do
humanoid:MoveTo(points[i])
wait(0.25)
end
humanoid:MoveTo(location.Value)
end
loco = 100000
torso.Touched:connect(attack)
wait(0.5)
end

if humanoid.Health == 0 or humanoid.Health < 0 then
wait(5)
newCharacter.Parent = Workspace
wait(0.1)
sp:Destroy()
end
Report Abuse
axelvts is not online. axelvts
Joined: 27 Apr 2008
Total Posts: 3029
28 Sep 2014 08:04 AM
e-e Really need this by the end of today......
Report Abuse
Mintacle is not online. Mintacle
Joined: 28 Aug 2013
Total Posts: 498
28 Sep 2014 08:08 AM
Lol too much to read
Report Abuse
axelvts is not online. axelvts
Joined: 27 Apr 2008
Total Posts: 3029
28 Sep 2014 08:09 AM
_-_ That's why I usually don't post long script to the forum.....
Report Abuse
axelvts is not online. axelvts
Joined: 27 Apr 2008
Total Posts: 3029
28 Sep 2014 08:12 AM
Because then too many people start to ignore it JUST for that reason.....
Report Abuse
axelvts is not online. axelvts
Joined: 27 Apr 2008
Total Posts: 3029
28 Sep 2014 09:30 AM
NM but thanks anyways guys! I fixed it! : D
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image