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: Help with CFrame animation

Previous Thread :: Next Thread 
sharpchain1 is not online. sharpchain1
Joined: 05 Aug 2013
Total Posts: 1009
29 Jul 2016 12:38 AM
So I am not very good with CFrame and to try and improve my skills with it I got one of the animations I made a bit ago and tried to replicate it using lerp. So I got all the CFrames of the poses in the animation but now I'm not sure what to do. Do I edit the C0 or the C1 of the motor6D and what CFrame do I lerp from? And how do I know how big/small to make the alpha perameter of the lerp method any help is appreciated
Report Abuse
sharpchain1 is not online. sharpchain1
Joined: 05 Aug 2013
Total Posts: 1009
29 Jul 2016 12:56 AM
Bump
Report Abuse
sharpchain1 is not online. sharpchain1
Joined: 05 Aug 2013
Total Posts: 1009
29 Jul 2016 01:13 AM
Bump
Report Abuse
sharpchain1 is not online. sharpchain1
Joined: 05 Aug 2013
Total Posts: 1009
29 Jul 2016 01:31 AM
bump3
Report Abuse
sharpchain1 is not online. sharpchain1
Joined: 05 Aug 2013
Total Posts: 1009
29 Jul 2016 01:53 AM
BUMP4
Report Abuse
sharpchain1 is not online. sharpchain1
Joined: 05 Aug 2013
Total Posts: 1009
29 Jul 2016 02:03 AM
BUUUUUUMMMP 5
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Jul 2016 03:18 AM
for i=0,1,0.01 do

part.CFrame:Slerp(otherCFrame,i)

wait()

end
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Jul 2016 03:18 AM
You can use either C0 or C1 but what they start out as will matter when animating and replace part.CFrame to weld.C0 or weld.C1
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
29 Jul 2016 03:19 AM
Oops dont think there is a Slerp yet so try lerp
Report Abuse
Everoso is not online. Everoso
Joined: 26 Jul 2016
Total Posts: 189
29 Jul 2016 03:25 AM
lerp slerps


Report Abuse
sharpchain1 is not online. sharpchain1
Joined: 05 Aug 2013
Total Posts: 1009
29 Jul 2016 11:38 AM
@blarg thx a lot it rly helped
Report Abuse
sharpchain1 is not online. sharpchain1
Joined: 05 Aug 2013
Total Posts: 1009
29 Jul 2016 01:26 PM
Ok so I did what u said and the cframed animation plays fine now. But the only problem is that it is not nearly as smooth as it is in the animation editor, do you have any ideas on how to make it just as smooth?
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
29 Jul 2016 01:50 PM
local start = part.CFrame
local goal = otherCFrame
for alpha=0,1,0.01 do

part.CFrame = start:lerp(goal,alpha)

wait()

end


What blarg posted wasn't linear, it was exponential
Report Abuse
Weirdraidercs35 is not online. Weirdraidercs35
Joined: 14 May 2015
Total Posts: 2275
29 Jul 2016 01:51 PM
use this module>
local module = {}

-- t = time == how much time has to pass for the tweening to complete
-- b = begin == starting property value
-- c = change == ending - beginning
-- d = duration == running time. How much time has passed *right now*

easingStyles = {
--Linear
Linear = function(t, b, c, d)
return c * t / d + b
end,

--Quad
inQuad = function(t, b, c, d)
return c * math.pow(t / d, 2) + b
end,

outQuad = function(t, b, c, d)
t = t / d
return -c * t * (t - 2) + b
end,

inOutQuad = function(t, b, c, d)
t = t / d * 2
if t < 1 then return c / 2 * math.pow(t, 2) + b end
return -c / 2 * ((t - 1) * (t - 3) - 1) + b
end,

outInQuad = function(t, b, c, d)
if t < d / 2 then return easingStyles.outQuad(t * 2, b, c / 2, d) end
return easingStyles.inQuad((t * 2) - d, b + c / 2, c / 2, d)
end,

--Cubic
inCubic = function(t, b, c, d)
return c * math.pow(t / d, 3) + b
end,

outCubic = function(t, b, c, d)
return c * (math.pow(t / d - 1, 3) + 1) + b
end,

inOutCubic = function(t, b, c, d)
t = t / d * 2
if t < 1 then return c / 2 * t * t * t + b end
t = t - 2
return c / 2 * (t * t * t + 2) + b
end,

outInCubic = function(t, b, c, d)
if t < d / 2 then return easingStyles.outCubic(t * 2, b, c / 2, d) end
return easingStyles.inCubic((t * 2) - d, b + c / 2, c / 2, d)
end,


--Quart

inQuart = function(t, b, c, d)
return c * math.pow(t / d, 4) + b
end,

outQuart = function(t, b, c, d)
return -c * (math.pow(t / d - 1, 4) - 1) + b
end,

inOutQuart = function(t, b, c, d)
t = t / d * 2
if t < 1 then return c / 2 * math.pow(t, 4) + b end
return -c / 2 * (math.pow(t - 2, 4) - 2) + b
end,

outInQuart = function(t, b, c, d)
if t < d / 2 then return easingStyles.outQuart(t * 2, b, c / 2, d) end
return easingStyles.inQuart((t * 2) - d, b + c / 2, c / 2, d)
end,

--Quint

inQuint = function(t, b, c, d)
return c * math.pow(t / d, 5) + b
end,

outQuint = function(t, b, c, d)
return c * (math.pow(t / d - 1, 5) + 1) + b
end,

inOutQuint = function(t, b, c, d)
t = t / d * 2
if t < 1 then return c / 2 * math.pow(t, 5) + b end
return c / 2 * (math.pow(t - 2, 5) + 2) + b
end,

outInQuint = function(t, b, c, d)
if t < d / 2 then return easingStyles.outQuint(t * 2, b, c / 2, d) end
return easingStyles.inQuint((t * 2) - d, b + c / 2, c / 2, d)
end,

--Sine

inSine = function(t, b, c, d)
return -c * math.cos(t / d * (math.pi / 2)) + c + b
end,

outSine = function(t, b, c, d)
return c * math.sin(t / d * (math.pi / 2)) + b
end,

inOutSine = function(t, b, c, d)
return -c / 2 * (math.cos(math.pi * t / d) - 1) + b
end,

outInSine = function(t, b, c, d)
if t < d / 2 then return easingStyles.outSine(t * 2, b, c / 2, d) end
return easingStyles.inSine((t * 2) -d, b + c / 2, c / 2, d)
end,

--Expo

inExpo = function(t, b, c, d)
if t == 0 then return b end
return c * math.pow(2, 10 * (t / d - 1)) + b - c * 0.001
end,

outExpo = function(t, b, c, d)
if t == d then return b + c end
return c * 1.001 * (-math.pow(2, -10 * t / d) + 1) + b
end,

inOutExpo = function(t, b, c, d)
if t == 0 then return b end
if t == d then return b + c end
t = t / d * 2
if t < 1 then return c / 2 * math.pow(2, 10 * (t - 1)) + b - c * 0.0005 end
return c / 2 * 1.0005 * (-math.pow(2, -10 * (t - 1)) + 2) + b
end,

outInExpo = function(t, b, c, d)
if t < d / 2 then return easingStyles.outExpo(t * 2, b, c / 2, d) end
return easingStyles.inExpo((t * 2) - d, b + c / 2, c / 2, d)
end,

--Circ

inCirc = function(t, b, c, d)
return(-c * (math.sqrt(1 - math.pow(t / d, 2)) - 1) + b)
end,

outCirc = function(t, b, c, d)
return(c * math.sqrt(1 - math.pow(t / d - 1, 2)) + b)
end,

inOutCirc = function(t, b, c, d)
t = t / d * 2
if t < 1 then return -c / 2 * (math.sqrt(1 - t * t) - 1) + b end
t = t - 2
return c / 2 * (math.sqrt(1 - t * t) + 1) + b
end,

outInCirc = function(t, b, c, d)
if t < d / 2 then return easingStyles.outCirc(t * 2, b, c / 2, d) end
return easingStyles.inCirc((t * 2) - d, b + c / 2, c / 2, d)
end,



--Back
outBack = function(t, b, c, d, s)
s = s or 1.2
t = t / d - 1
return c * (t * t * ((s + 1) * t + s) + 1) + b
end,

inBack = function(t, b, c, d, s)
s = s or 1.70158
t = t / d
return c * t * t * ((s + 1) * t - s) + b
end,

inOutBack = function(t, b, c, d, s)
s = (s or 1.70158) * 1.525
t = t / d * 2
if t < 1 then return c / 2 * (t * t * ((s + 1) * t - s)) + b end
t = t - 2
return c / 2 * (t * t * ((s + 1) * t + s) + 2) + b
end,

outInBack = function(t, b, c, d, s)
if t < d / 2 then return easingStyles.outBack(t * 2, b, c / 2, d, s) end
return easingStyles.inBack((t * 2) - d, b + c / 2, c / 2, d, s)
end,

--bounce

outBounce = function(t, b, c, d)
t = t / d
if t < 1 / 2.75 then return c * (7.5625 * t * t) + b end
if t < 2 / 2.75 then
t = t - (1.5 / 2.75)
return c * (7.5625 * t * t + 0.75) + b
elseif t < 2.5 / 2.75 then
t = t - (2.25 / 2.75)
return c * (7.5625 * t * t + 0.9375) + b
end
t = t - (2.625 / 2.75)
return c * (7.5625 * t * t + 0.984375) + b
end,

inBounce = function(t, b, c, d)
return c - easingStyles.outBounce(d - t, 0, c, d) + b
end,

inOutBounce = function(t, b, c, d)
if t < d / 2 then return easingStyles.inBounce(t * 2, 0, c, d) * 0.5 + b end
return easingStyles.outBounce(t * 2 - d, 0, c, d) * 0.5 + c * .5 + b
end,

outInBounce = function(t, b, c, d)
if t < d / 2 then return easingStyles.outBounce(t * 2, b, c / 2, d) end
return easingStyles.inBounce((t * 2) - d, b + c / 2, c / 2, d)
end
}


module.interpolateWeld = function(Weld,NewC1,easingStyle,Duration)
spawn(function()
math.randomseed(tick() * math.random() * math.random())
easingStyle = easingStyle or 'Linear'
local NewCode = math.random(-1e9,1e9)
if Weld:FindFirstChild('TweenIndication') then
Weld:FindFirstChild('TweenIndication').Value = NewCode
else
local tweenIndication = Instance.new('NumberValue',Weld)
tweenIndication.Name = 'TweenIndication'
tweenIndication.Value = NewCode
end
local tweenIndication = Instance.new('NumberValue',Weld)
local StartTime = tick()
local StartC1 = Weld.C1
while game:GetService('RunService').RenderStepped:wait() do
if Weld:FindFirstChild('TweenIndication').Value ~= NewCode then
break
end
local alpha
if tick() >= StartTime + Duration then
alpha = 1
else
alpha = (tick() - StartTime)/Duration
end
Weld.C1 = StartC1:lerp(NewC1,easingStyles[easingStyle](alpha,0,1,1))
if tick() >= StartTime + Duration or Weld:FindFirstChild('TweenIndication').Value ~= NewCode then
break
end
end
end)
end

module.OffsetInterpolate = function(Weld,NewC0,easingStyle,Duration)
spawn(function()
easingStyle = easingStyle or 'Linear'
math.randomseed(tick() * math.random() * math.random())
local NewCode = math.random(-1e9,1e9)
if Weld:FindFirstChild('TweenC0') then
Weld:FindFirstChild('TweenC0').Value = NewCode
else
local tweenIndication = Instance.new('NumberValue',Weld)
tweenIndication.Name = 'TweenC0'
tweenIndication.Value = NewCode
end
local tweenIndication = Instance.new('NumberValue',Weld)
local StartTime = tick()
local StartC0 = Weld.C0
while game:GetService('RunService').RenderStepped:wait() do
if Weld:FindFirstChild('TweenC0').Value ~= NewCode then
break
end
local alpha
if tick() >= StartTime + Duration then
alpha = 1
else
alpha = (tick() - StartTime)/Duration
end
Weld.C0 = StartC0:lerp(NewC0,easingStyles[easingStyle](alpha,0,1,1))
if tick() >= StartTime + Duration or Weld:FindFirstChild('TweenC0').Value ~= NewCode then
break
end
end
end)
end

module.Styles = easingStyles




return module





im a mlg
Report Abuse
lego555444 is not online. lego555444
Joined: 21 Sep 2008
Total Posts: 1383
29 Jul 2016 01:51 PM
Use c1 to set the start position offset so that c0 will always be at the orientation when c0 = CFrame.new()


Check out my game: https://www.roblox.com/games/262422056/_
Report Abuse
sharpchain1 is not online. sharpchain1
Joined: 05 Aug 2013
Total Posts: 1009
29 Jul 2016 02:17 PM
@weird

thx... Ill try to decipher that and get just the stuff I want
Report Abuse
Weirdraidercs35 is not online. Weirdraidercs35
Joined: 14 May 2015
Total Posts: 2275
29 Jul 2016 02:20 PM
no, put it in a module script in the startergui and it makes animating welds so much smoother

you can use it liek this >
Tween=require(player.PlayerGui.pls)
Tween.OffsetInterpolate(RightWeld, (CFrame.new(0, 3, 0) * Offset), "Linear", 0.1)


im a mlg
Report Abuse
sharpchain1 is not online. sharpchain1
Joined: 05 Aug 2013
Total Posts: 1009
29 Jul 2016 04:38 PM
Ik but I don't want a whole module for that I just want linear interpolation
Report Abuse
SadisticNub is not online. SadisticNub
Joined: 05 Jan 2013
Total Posts: 4948
29 Jul 2016 04:39 PM
That module... Jesus.
Report Abuse
sharpchain1 is not online. sharpchain1
Joined: 05 Aug 2013
Total Posts: 1009
29 Jul 2016 04:42 PM
Also that "d" variable is supposed to equal right now so do u mean I'm supposed to assign it to tick()?
Report Abuse
sharpchain1 is not online. sharpchain1
Joined: 05 Aug 2013
Total Posts: 1009
29 Jul 2016 04:45 PM
Actualy I'm kinda confused about all the bait ales there except for the t variable
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
29 Jul 2016 05:54 PM
"math.randomseed(tick() * math.random() * math.random())"
*facepalm*
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