Game Development Community

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:

www.matrixlab-examples.com/image-files/periodic-function-002.gif

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.


#1
05/16/2012 (9:53 am)
Check out the Path objects. You can make it so pressing a direction will move you to the next node in the path.