|
| 07 Nov 2016 03:31 AM |
Hi,
So in my game I have 4 checkpoints for an animation using CFrame:lerp. Basically when the part lerps to checkpoint 1, it begins lerping to checkpoint 2 then lerps to checkpoint 3.
So far I've only managed to get it to lerp to checkpoint 2 from checkpoint 1. But I can't seem to find a way to make it lerp to checkpoint 3 and so on immediately. In the script I have removed my attempt to lerp to the next checkpoint . Heres the script:
part = game.Workspace.Part plane = game.Workspace.Plane c1 = game.Workspace.Checkpoint1 c2 = game.Workspace.Checkpoint2 c3 = game.Workspace.Checkpoint3 c4 = game.Workspace.Checkpoint4
function interpolate1() wait(5) for i=0,1,0.1 do part.CFrame = c1.CFrame:lerp(c2.CFrame,i) wait(0.1) end end interpolate1()
So can someone here please tell me what I need to add to the script next? Thanks!
And how do I make the animation a bit smoother too? So far it looks stuttery. |
|
|
| Report Abuse |
|
|
Laedere
|
  |
| Joined: 17 Jun 2013 |
| Total Posts: 23601 |
|
|
| 07 Nov 2016 03:51 AM |
| change for i=0,1,0.1 do to for i=0,1,0.01 do for a more smooth animation |
|
|
| Report Abuse |
|
|
| |
|
|
| 07 Nov 2016 07:18 AM |
Use integers instead
for i=0,100 do --i/100 end
And also to make them smoother you can try using trigonometry -math.cos(i/100*math.pi)/2+0.5 --smooth from 0 to 1 or make your own tween function |
|
|
| Report Abuse |
|
|
|
| 07 Nov 2016 07:25 AM |
I don't really understand what you want, you mean like this?
function interpolate1() wait(5) for i=0,1,0.1 do part.CFrame = c1.CFrame:lerp(c2.CFrame,i) wait(0.1) end for i=0,1,0.1 do part.CFrame = c2.CFrame:lerp(c3.CFrame,i) wait(0.1) end end interpolate1()
It seems too simple for you to miss so I'm not sure if its what you wanted. |
|
|
| Report Abuse |
|
|
|
| 07 Nov 2016 07:29 AM |
part = game.Workspace.Part plane = game.Workspace.Plane c1 = game.Workspace.Checkpoint1 c2 = game.Workspace.Checkpoint2 c3 = game.Workspace.Checkpoint3 c4 = game.Workspace.Checkpoint4
function interpolate(c1, c2) wait(5) for i=0,1,0.1 do part.CFrame = c1.CFrame:lerp(c2.CFrame,i) wait() - might be better, but using Body Movers would be smooth end end
while true do interpolate(c1, c2) interpolate(c2, c3) interpolate(c3, c4) interpolate(c4, c1) end -- while
|
|
|
| Report Abuse |
|
|
|
| 07 Nov 2016 08:19 AM |
function interpolate(speed,...) local start=obj.CFrame for _,point in next,{...} do for i=0,speed,math.abs(speed-math.floor(speed)) do obj.CFrame = start:Lerp(point,i/speed) wait(1/speed) end obj.CFrame=point start=point end end
interpolate(10.5,c1,c2,c3,c4) |
|
|
| Report Abuse |
|
|
|
| 07 Nov 2016 11:24 AM |
| I need CFrame lerp help too! |
|
|
| Report Abuse |
|
|
| |
|
| |
|