Survival Project
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Keyframe animation system

3 posters

Go down

Keyframe animation system Empty Keyframe animation system

Post by jobro13 Wed Oct 23, 2013 11:45 am

Roblox has already announced it own Keyframe animation system, using their OWN instances. I already made one though and it's integrated in SE. It's usage is extremely simple - I am going to use the animation system to make "clean" transistions between walking / falling / sitting - etc. I am not gonna use my Sine class for that anymore. The sines are okay, but the transistions are a big problem.

Here two videos:



The usage is extremely simple. An animation consists of "Keyframe" classes. These hold data on what welds need which offset (so, welding is for now the only prerequiste) on what time. These can be passed on via the :AddWeldState method of Keyframe - this one takes the Welds' name (not the actual object! Like this, we can save welds as presets (because most instances are refreshed on every respawn, such as the character!!)), a table with offsets, an optional TweenStyle and TweenDirection.

The table offset all has optional values. {x = 3, y = 2, angx = math.pi, angz = math.pi * 2} means that the weld's C0 property has to tween to x = 3, y = 2, (the z property will stay as it is!), and the angle will be 180 degrees rolling on the x axis and 360 degrees rolling on the z axis. The y axis isn't touched.

Then, you define a .Time property of the Keyframe;

Frame1.Time = 2

This means that these offsets have to be reached at t = 2 seconds.

When you created all keyframes you create a new Animation object;

MyAnimation = Create("Animation")

Then, flush all keyframes in the animation;

MyAnimation:AddKeyframe(Frame1)
...
MyAnimation:AddKeyframe(Frame17)


Then, optinally mark it "looped"

MyAnimation.Looped = true

Set the root - very important:

MyAnimation.Root = Character.FakeTorso -- Which is the Weld container of all limbs.

And then play!!

MyAnimation:Play()


Example handshake code:

Code:
local Frame1 = Create("Keyframe")
Frame1:AddWeldState("Right Shoulder", {angz = -3})
Frame1.Time = 0.5
local Frame2 = Create("Keyframe")
Frame2:AddWeldState("Right Shoulder", {angx = -0.16, angz = -3})
Frame2.Time = 0.8
local Frame3 = Create("Keyframe")
Frame3:AddWeldState("Right Shoulder", {angx = 0.55, angz = -3})
Frame3.Time = 1.1
Frame4 = Create("Keyframe")
Frame4:AddWeldState("Right Shoulder", {angx = -0.16, angz = -3})
Frame4.Time = 1.4
Frame5 = Create("Keyframe")
Frame5.Time = 1.9
Frame5:AddWeldState("Right Shoulder", {angx = 0, angz = 0})

local Wave = Create("Animation")

for i,v in pairs({Frame1,Frame2,Frame3,Frame4,Frame5}) do
Wave:AddKeyframe(v)
end

Wave.Root = game.Workspace.Player1.FakeTorso
Wave:Play()
Also, this class uses TweenService to interpolate. TweenService is basically a Library full of interpolation functions.
jobro13
jobro13

Male Posts : 250
Join date : 2013-06-02

Back to top Go down

Keyframe animation system Empty Re: Keyframe animation system

Post by Fattycat17 Wed Oct 23, 2013 2:46 pm

Sweet! Looks amazing, cant wait for the alpha version!
Fattycat17
Fattycat17

Male Posts : 116
Join date : 2013-06-02

Back to top Go down

Keyframe animation system Empty Re: Keyframe animation system

Post by coolieman2 Thu Oct 31, 2013 11:58 am

Well, IF THIS IS HOW SE IS GOING TO BE THEN IT IS AWESOME
I have nothing more to say.
If the text is too large:
coolieman2
coolieman2

Male Posts : 78
Join date : 2013-06-21
Location : Europe meaning i'm in a good timezone :)

Back to top Go down

Keyframe animation system Empty Re: Keyframe animation system

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum