Tweening

Scripts and code that enhance the gameplay functionality of the engine.
25 posts Page 3 of 3
rlranft
Posts: 298
Joined: Thu Feb 05, 2015 3:11 pm
 
by rlranft » Wed Mar 04, 2015 4:42 pm
Oh man, moving platforms - another thing you'd think would be easy....
Gibby
Posts: 72
Joined: Wed Feb 11, 2015 2:40 pm
by Gibby » Wed Mar 04, 2015 7:08 pm
@
User avatar
LukasPJ
:

per your suggestion adding this at line 22, exactly as in Impact, worked!

Code: Select all

   virtual void interpolateTick( F32 delta ) {};
   virtual void processTick() {};



...I'll have to edit the video tonight after work but I've setup a scripted turret using the 'deathball desert' shapes - nice 'n fun...
cybore
Posts: 16
Joined: Fri Feb 13, 2015 10:18 am
by cybore » Wed Mar 04, 2015 11:18 pm
Awesome! Thank you for pointing this out Gibby!
Gibby
Posts: 72
Joined: Wed Feb 11, 2015 2:40 pm
by Gibby » Thu Mar 05, 2015 3:57 am
@
User avatar
LukasPJ
:

Can you help me with something? I have the old 'deathball desert' turrets working entirely in script. The only thing I've lacked has been a way to smooth out the movement. I'd like to use a Tween for this, but I'm not sure I'm setting it up correctly.

here's my little function:

function aimTurret(%turret)
{
%target = %turret.target;
echo("stationTurretTrigger::aimTurret %turret "@%turret@" target "@%target);

if(isObject(%target))
{
echo("stationTurretTrigger::aimTurret %target valid");
%turretPos = %turret.getPosition();
%tgtPos = %target.getPosition();
// this function returns the rotation '%rot' needed to point the turret at its target
%rot = pointToPos(%turretPos, %tgtPos);

if(%turret.tween !$= "")
{
%turret.tween.delete();
%turret.tween = "";
}

%turret.tween = new Tween()
{
Duration = 1; // This is in seconds.
Target = %turret; // Any SimObject.
ValueName = "r"; // "r" for rotation?
ValueTarget = %rot; // should I be placing the destination rot value here?
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.
};

echo("stationTurretTrigger::aimTurret %tween: "@%turret.tween);
%turret.tween.play();
// need an 'onFinished' call here to fire the weapon...

}
}


My other question is how to setup the 'onFinished' call - I want to pull the turret's trigger as soon as the tween is finished...
LukasPJ
Site Admin
Posts: 358
Joined: Tue Feb 03, 2015 7:25 pm
 
by LukasPJ » Thu Mar 05, 2015 6:25 pm
@
User avatar
Gibby
unfortunately, it's a fairly simple class atm so you'd need one tween for each axis the turret needs to rotate on. I might improve this later on :)
This is written by hand so there maybe syntactical issues:
function aimTurret(%turret)
{
%target = %turret.target;
echo("stationTurretTrigger::aimTurret %turret "@%turret@" target "@%target);

if(isObject(%target))
{
echo("stationTurretTrigger::aimTurret %target valid");
%turretPos = %turret.getPosition();
%tgtPos = %target.getPosition();
// this function returns the rotation '%rot' needed to point the turret at its target
%rot = pointToPos(%turretPos, %tgtPos);

if(%turret.tween !$= "")
{
%turret.tween.delete();
%turret.tween = "";
}

%turret.tween = new Tween(TurretTween)
{
Duration = 1; // This is in seconds.
Target = %turret; // Any SimObject.
ValueName = "rz"; // "r" for rotation, "z" for axis
ValueTarget = %rot.z; // should I be placing the destination rot value here?
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.

// Dynamics
Turret = %turret; //Wooh circular references!
};

echo("stationTurretTrigger::aimTurret %tween: "@%turret.tween);
%turret.tween.play();
}
}

function TurretTween::onFinished(%this)
{
%this.turret.fire-away_fire-away();
}
25 posts Page 3 of 3

Who is online

Users browsing this forum: No registered users and 1 guest