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 » Scripters
Home Search
 

Re: CFrame:lerp help

Previous Thread :: Next Thread 
Alectfenrir123 is not online. Alectfenrir123
Joined: 23 Mar 2010
Total Posts: 405
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 is online. 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
Alectfenrir123 is not online. Alectfenrir123
Joined: 23 Mar 2010
Total Posts: 405
07 Nov 2016 06:29 AM
Bump
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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
enzotinman1 is not online. enzotinman1
Joined: 22 Jun 2012
Total Posts: 408
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
BJCarpenter is online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
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
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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
RubyEpicDragon is not online. RubyEpicDragon
Joined: 02 May 2015
Total Posts: 1211
07 Nov 2016 11:24 AM
I need CFrame lerp help too!
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
07 Nov 2016 11:25 AM
^ nobody asked
Report Abuse
RubyEpicDragon is not online. RubyEpicDragon
Joined: 02 May 2015
Total Posts: 1211
07 Nov 2016 11:27 AM
:c
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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