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: quick question, how to make a moving brick?

Previous Thread :: Next Thread 
yurhomi10 is not online. 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
MomoiroCloverZ is not online. MomoiroCloverZ
Joined: 06 Jan 2013
Total Posts: 825
30 Jul 2014 09:19 PM
um bodyposition ._.


MomoiroCloverZ, newbag expert Lua coder.
Report Abuse
yurhomi10 is not online. 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
MomoiroCloverZ is not online. MomoiroCloverZ
Joined: 06 Jan 2013
Total Posts: 825
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 is not online. 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
MomoiroCloverZ is not online. MomoiroCloverZ
Joined: 06 Jan 2013
Total Posts: 825
30 Jul 2014 09:24 PM
because the bodyposition object moves an object smoothly


MomoiroCloverZ, newbag expert Lua coder.
Report Abuse
yurhomi10 is not online. 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 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
30 Jul 2014 09:27 PM
CFrame?
Report Abuse
BruceAB12 is not online. 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
MomoiroCloverZ is not online. MomoiroCloverZ
Joined: 06 Jan 2013
Total Posts: 825
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 is not online. 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 is not online. 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 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
30 Jul 2014 09:31 PM
Woah :o
Report Abuse
yurhomi10 is not online. 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 is not online. 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
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