Page 3 of 3

Re: Tweening

Posted: Wed Mar 04, 2015 4:42 pm
by rlranft
Oh man, moving platforms - another thing you'd think would be easy....

Re: Tweening

Posted: Wed Mar 04, 2015 7:08 pm
by Gibby
@
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...

Re: Tweening

Posted: Wed Mar 04, 2015 11:18 pm
by cybore
Awesome! Thank you for pointing this out Gibby!

Re: Tweening

Posted: Thu Mar 05, 2015 3:57 am
by Gibby
@
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...

Re: Tweening

Posted: Thu Mar 05, 2015 6:25 pm
by LukasPJ
@
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();
}