yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 30 Jul 2014 09:17 PM |
So, with the new addition of the smart AI for NPC's, I thought of how to make a path from one point to another. Well, I wanted to make a brick follow that path but my problem is, how would make it move smoothly and not have a brick hop to their newly given position
while wait(0.1) do path = game:GetService("PathfindingService"):ComputeRawPathAsync(game.Workspace.Start.Position, game.Workspace.End.Position,300) points = path:GetPointCoordinates() game.Workspace.Bricks:ClearAllChildren() for i = 1, #points do x = Instance.new("Part", game.Workspace.Bricks) x.Name = "brick" x.Size = Vector3.new(1,1,1) x.BrickColor = BrickColor.new("Really black") x.Transparency = 0.5 x.Position = points[i] x.Anchored = true x.CanCollide = false end end
|
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 09:19 PM |
um bodyposition ._.
MomoiroCloverZ, newbag expert Lua coder. |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 30 Jul 2014 09:21 PM |
| I get that, but the script I have is creating a path made of bricks. I want to make a brick follow that same path but I don't want it teleporting. I'm not asking for it to be made, I just need help on how to transition from one position to the next smoothly. |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 09:23 PM |
My question is why cant you just use a bodyposition and change the position property of the bodyposition each time it reaches the target point
MomoiroCloverZ, newbag expert Lua coder. |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 30 Jul 2014 09:23 PM |
| why would I add that when I can just use part.Position..? |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 09:24 PM |
because the bodyposition object moves an object smoothly
MomoiroCloverZ, newbag expert Lua coder. |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 30 Jul 2014 09:25 PM |
..oh.
good point lol,
but what if I didn't want to use body position, would I have to use another for or something? Just being practical but it could happen. |
|
|
| Report Abuse |
|
|
BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
| |
|
BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
|
| 30 Jul 2014 09:29 PM |
for i = 1, #points do wait(0.01) Brick.CFrame = points[i] end
Something like that idk lel |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 09:29 PM |
local oldpos local newpos local travel = (oldpos-newpos).unit*-1 --got too lazy to fix while (brick.Position-newpos).magnitude > 1 do wait() brick.CFrame = brick.CFrame+travel end
MomoiroCloverZ, newbag expert Lua coder. |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 30 Jul 2014 09:29 PM |
| that would do the same thing I believe |
|
|
| Report Abuse |
|
|
00doggie
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 337 |
|
|
| 30 Jul 2014 09:30 PM |
use a linear convex combination of the start and end point.
If a number A is between 0 and 1 and you have two points x and y then the line between x and y is
x * (1-A) + y * A
while A goes from 0 to 1.
In ROBLOX you might try to do
for i = 0, 100 do position = vector3.new(x.X * (1 - i/100) + y.X * i/100, x.Y * (1 - i/100) + y.Y * i/100, x.Z * (1 - i/100) + y.Z * i/100) -- do something with that position end
|
|
|
| Report Abuse |
|
|
BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
| |
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 30 Jul 2014 09:33 PM |
| this is all so confusing for me, thanks math 0.0 |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 30 Jul 2014 09:43 PM |
This isn't working, I think I'm not using the body object right.. help?
path = game:GetService("PathfindingService"):ComputeRawPathAsync(game.Workspace.Start.Position, game.Workspace.End.Position,300) points = path:GetPointCoordinates()
x = Instance.new("Part", game.Workspace) p = Instance.new("BodyPosition", x) x.Name = "brick" x.Size = Vector3.new(1,1,1) x.BrickColor = BrickColor.new("Really black") x.Transparency = 0.5 x.Anchored = true x.CanCollide = false wait(0.1) for i = 1, #points do wait(0.1) x.BodyPosition.position = points[i] end |
|
|
| Report Abuse |
|
|