Square Wave Function
by Ganef · in Artist Corner · 05/15/2012 (9:26 pm) · 1 replies
How do I use math functions within TorqueScript?
Say I have my basic script:
function FishClass::onLevelLoaded(%this, %scenegraph)
{
%this.setLinearVelocityX(20);
}
And say I wanted to make my FishClass move in a really jagged way, like an old Game and Watch handheld. Like this:
www.youtube.com/watch?v=HfKoEWN65Qo
I want to use a function would be a square wave. Like this:

So how does a person do that? Hell, even if it was a simple sine function, how would I plug it in?
Say I have my basic script:
function FishClass::onLevelLoaded(%this, %scenegraph)
{
%this.setLinearVelocityX(20);
}
And say I wanted to make my FishClass move in a really jagged way, like an old Game and Watch handheld. Like this:
www.youtube.com/watch?v=HfKoEWN65Qo
I want to use a function would be a square wave. Like this:

So how does a person do that? Hell, even if it was a simple sine function, how would I plug it in?
About the author
A nomad, fighting against the apparatus of the state throughout the deserts of the horizon of the infinite.
Torque 3D Owner Luis E Pabon
Independent