### Tweening

Scripts and code that enhance the gameplay functionality of the engine.

#### Tweening

LukasPJ
Posts: 344
Joined: Tue Feb 03, 2015 7:25 pm

Hey guys, I wrote a Tweening class for Torque3D that can be found here.

It's pretty simple to use:
%tween = new Tween(){   Duration = 5; // This is in seconds.   Target = SimpleWall; // Any SimObject.   ValueName = "x"; // Syntactic sugar for the x-coordinate.   ValueTarget = "5"; // The destination value, this is the absolute value. No relative supported atm.   EaseDirection = $Ease::Out; // This is just the stock easing values. EaseType =$Ease::Circular; // Again, this is a stock thing, I didn't implement the \$Ease enum.};%tween.play();

There is syntactic sugar for:
Position (x, y, z).
Rotation(rx, ry, rz).
Scale(sx, sy, sz).

But any numerical field that is accessible through TorqueScript can be used. (Includes globals).

The Tween class has the following methods:
• Play - Starts the tween
• Pause - Pauses the tween
• Rewind - Rewinds the tween back to the beginning (does not stop it currently)
• Reverse - Plays the tween in reverse

And an "onFinished" callback.

The code is not completely finished, but it's fun to play with!

#### Re: Tweening

rlranft
Posts: 298
Joined: Thu Feb 05, 2015 3:11 pm

Nice - I snagged Charlie's Twillex stuff from T2D, but so far all I've used it for is some GUI stuff....

#### Re: Tweening

Steve_Yorkshire
Posts: 201
Joined: Tue Feb 03, 2015 10:30 pm

Tweening? What the hell is tweening!?
There some old TorqueScript for moving stuff around in the old library.cs file that I remember using once.

#### Re: Tweening

LukasPJ
Posts: 344
Joined: Tue Feb 03, 2015 7:25 pm

Steve_Yorkshire wrote:Tweening? What the hell is tweening!?
There some old TorqueScript for moving stuff around in the old library.cs file that I remember using once.

This can do more than just move stuff around! (Also library.cs? What file is that? )

For example you could change its scale so it would get wider over time Or rotate it in weird ways. It's basically a C++ version of Twillex

#### Re: Tweening

Steve_Yorkshire
Posts: 201
Joined: Tue Feb 03, 2015 10:30 pm

@
LukasPJ

Twillex? I thought that was a dubstep DJ or someone ...

Library.cs is an ancient file or TorqueScript which predates the Phanerozoic Era by half a billion years. It's full of fancy script utilities and mathematics before TGE had them integrated into C++ and the like.

#### Re: Tweening

rlranft
Posts: 298
Joined: Thu Feb 05, 2015 3:11 pm

"Tweening" - from "in between keyframes," it means to draw the animation frames between the keys provided - or "inbetweening." See http://en.wikipedia.org/wiki/Inbetweening

Twillex - Scripts to aid simple animation sequences in T2D. See http://www.garagegames.com/community/blogs/view/21480

#### Re: Tweening

buckmaster
Steering Committee
Posts: 321
Joined: Thu Feb 05, 2015 1:02 am
I've been using Twillex and it's pretty great, though I noticed that it doesn't look at all smooth in T3D unless you do this (i.e. use ScriptTickObject and its callback).

#### Re: Tweening

LukasPJ
Posts: 344
Joined: Tue Feb 03, 2015 7:25 pm

buckmaster wrote:I've been using Twillex and it's pretty great, though I noticed that it doesn't look at all smooth in T3D unless you do this (i.e. use ScriptTickObject and its callback).

This is a C++ version of Twillex so it's pretty smooth already

#### Re: Tweening

RichardM
Posts: 32
Joined: Tue Feb 10, 2015 10:23 pm

Nice!

#### Re: Tweening

rlranft
Posts: 298
Joined: Thu Feb 05, 2015 3:11 pm

buckmaster wrote:I've been using Twillex and it's pretty great, though I noticed that it doesn't look at all smooth in T3D unless you do this (i.e. use ScriptTickObject and its callback).

It worked fine for simple GUI object movement - I made roll-out button panels that sit on the edges of the screen. I'll have to upload a short video later.
I've been contemplating translating this to C++ myself. It's a natural progression and as Daniel points out it's a better overall solution for T3D.

#### Who is online

Users browsing this forum: No registered users and 2 guests