Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Spring physics CFrame interpolation?

Asked by
Supint 60
9 years ago

I have this code right now (credit to treyreynolds) which deals with Vector3 positioning, but I need to figure out a way to convert it to using CFrames so I can "spring interpolate" angles. I can clarify further upon request. Right now, all it does is convert the Vector3 position to a CFrame without factoring in angular orientation.


dampen=0.5 speed=1 restpos=workspace.Part.Position pos=restpos vel=Vector3.new(0,0,100) while true do restpos = workspace.Part.Position local dt=wait()/speed local accel=restpos-pos-2*dampen*vel vel=vel+dt*accel pos=pos+dt*vel workspace.MovePart.CFrame = CFrame.new(pos) end
0
Since its a while true loop its important to add a wait() so it doesn't crashes the Studio. UserOnly20Characters 890 — 9y
0
On line 9 the script says "wait()/speed". That calls the wait() command and returns the length of the wait() command itself, which is rougly 1/30th of a second TurboFusion 1821 — 9y

Answer this question