Game Development Community

Rotating a non static object around it's z-axis.

by Dustin Clingman · in Technical Issues · 08/09/2007 (1:23 pm) · 0 replies

This is simple. I would like to have a powerup like item rotating around it's local z-axis. I have modified logoitem.cs with the following code.



// When Actor is added, start the intellect loop and set any initial orders
function TorqueLogoItem::onAdd(%this)
{
// Angle can be shared amongst all TorqueLogoItems.
$g_Angle = 0;

cancel(%this.updateLoop);
%this.updateLoop = %this.schedule(200, "updateObject");
}



// Updates the Actor.
// This function gets called every 200ms.
function TorqueLogoItem::updateObject(%this)
{
// Tick the actor.
%this.tick();


// Initiate new loop in 200ms
cancel(%this.updateLoop);
%this.updateLoop = %this.schedule(200, "updateObject");
}



// Ticks the Actor.
function TorqueLogoItem::tick(%this)
{
$g_Angle += 10;
if ($g_Angle >= 360)
$g_Angle -= 360;

%cosResult = mCos($g_Angle);

%rotation = "0 0 1 " @ $g_Angle;


// Update TorqueLogoItem's matrix.
echo("TorqueLogoItem::tick");
echo("rotation: ", %rotation);
}


I see the echos. I'm just not quite sure how to modify the matrix for the object. Any tips would be much apprietiated. Also, is schedule the best method of providing an update tick for an object?

About the author

Recent Threads