|
| 22 Mar 2015 04:25 PM |
How would I get a part to go from one set of coordinates to another without having to spam something like this? I would need it to keep bouncing from a,b,c to x,y,z then back to a,b,c then x,y,z etc.
local shrek = game.Workspace.Part local a = 0.05 shrek.Position = Vector3.new(CFrame.new(193, 183.8, -324.5)) wait(a) shrek.Position = Vector3.new(CFrame.new(193, 183.9, -324.5)) wait(a) shrek.Position = Vector3.new(CFrame.new(193, 184, -324.5)) wait(a) shrek.Position = Vector3.new(CFrame.new(193, 184.1, -324.5)) wait(a) shrek.Position = Vector3.new(CFrame.new(193, 184.2, -324.5)) BLAH BLAH BLAH
I don't want to waste my life typing one script... Thanks |
|
|
| Report Abuse |
|
|
Stefan631
|
  |
| Joined: 23 Dec 2010 |
| Total Posts: 1350 |
|
|
| 22 Mar 2015 04:46 PM |
local s = workspace.Part; local times = 10 --change for i = 0, times, .1 do -- starts at goes up by .1 until it reaches 'times' s.CFrame = s.CFrame + Vector3.new(0, i, 0); wait(); end; |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 22 Mar 2015 04:57 PM |
| if you want to be really fancy, look into sine/cosine, trigonometry, and CFrame interpolation |
|
|
| Report Abuse |
|
|
|
| 22 Mar 2015 04:57 PM |
local s = game.Workspace.LavaHeights.Lava; local times = 271.5 --change for i = 0, times, .01 do -- starts at goes up by .1 until it reaches 'times' s.CFrame = s.CFrame + Vector3.new(0, i, 0); wait(0.3); end;
So 271.5 is the y coordinate I want it to stop at but it just keeps going. Also, the speed at which the part is going upwards accumulates over time... It doesn't stay at a steady rate. |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
|
| 22 Mar 2015 05:01 PM |
local startPos = Vector3.new(193, 183.8, -324.5) local endPos = Vector3.new(193, 184.2, -324.5)
for i = 0, 1, 0.02 do shrek.CFrame = CFrame.new(startPos:lerp(endPos, i)) wait() end
-- change 0.02 (before 'do') to speed, lower is slower |
|
|
| Report Abuse |
|
|
|
| 22 Mar 2015 05:10 PM |
| Thank you soooo much NotAshley! You're a lifesaver. |
|
|
| Report Abuse |
|
|
NotAshley
|
  |
| Joined: 16 Jan 2014 |
| Total Posts: 14257 |
|
| |
|