| |
|
|
| 26 Feb 2015 02:55 PM |
Pathfinding consists of "points".
Here is a piece.
local service = game:GetService("PathfindingService") local path = service:ComputeRawPathAsync(startPosition, endPosition, float maxDistance)
points = path:GetPointCoordinates()
for _, point in pairs(points) do humanoid:MoveTo(point) repeat distance = (point -player.Character.Torso.Position).magnitude wait() until distance < 3 end |
|
|
| Report Abuse |
|
|
|
| 26 Feb 2015 02:57 PM |
Small revision:
ocal service = game:GetService("PathfindingService") local path = service:ComputeRawPathAsync(startPosition, endPosition, float maxDistance)
points = path:GetPointCoordinates()
for _, point in pairs(points) do humanoid:MoveTo(point) repeat distance = (point - torso.Position).magnitude wait() until distance < 3 end |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Feb 2015 03:13 PM |
Ah, in that case. You might want to rename that npc's humanoid. And use an infinite loop to check the magnitude of each player's torso. And if it is in range, the npc will use any means to get to you.
That would be the logic. |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Feb 2015 04:50 PM |
| I am on a linux/ubuntu OS right now. I am not really in the shape to script. |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Feb 2015 04:57 PM |
| I gave you an overview of pathfinding, and a bundle of code that does just that. Do you need anything else? |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Feb 2015 05:04 PM |
| Well, NPC's are pretty time consuming to make, especially making it walk, since you have all the joints. I just take a basic one out of free models and do whatever the flipping heck I want with it. |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Feb 2015 05:11 PM |
Try getting some information out of this.
http://wiki.roblox.com/index.php?title=Animations#Playing_Animation_in_Non-Player_Character
Tells you all the components you need, including the HumanoidRootPart |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Feb 2015 05:22 PM |
| Did I just give you the bit of code that computes a path from point A to point B? -.- |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Feb 2015 05:31 PM |
"while wait() do" loop.
Utilize magnitude. |
|
|
| Report Abuse |
|
|
|
| 26 Feb 2015 05:33 PM |
magnitude = (partA.Position - partB.Position).magnitude
radius = 200 -- distance
while wait() do
if magnitude < radius then end
end
This will fire when a part comes in range. |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Feb 2015 05:50 PM |
| What exactly do you mean by codes? Connect the pathfinding bit of code I gave you to the magnitude bit. I think you could figure it out. |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Feb 2015 05:57 PM |
It does just that.
and simple, alter the meaning of the variable used to define the target point your NPC is supposed to walk to. :) |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Feb 2015 06:01 PM |
| THat sir, is the purpose of that while loop. xD |
|
|
| Report Abuse |
|
|
| |
|