Rotation
by James Higgins · in Torque Game Builder · 08/22/2007 (3:02 pm) · 2 replies
What do you use to change the rotation of an object in torque script?
Also, how do you replace the mouse cursor?
Also, how do you replace the mouse cursor?
About the author
#2
I didn't notice the TGB reference section in the documentation before, now things should be a bit easier to work out..
08/23/2007 (8:53 am)
Thanks!I didn't notice the TGB reference section in the documentation before, now things should be a bit easier to work out..
Associate James Ford
Sickhead Games
sceneobjectname.setRotation(float)
or, for a smooth rotation
sceneobjectname.rotateTo(float rotationTarget, float angularSpeed,[bool autoStop=true],[bool callback=false],[bool snap=true],[float targetMargin=0.1])
Description: Sets a rotation target for the object and rotates toward it. The object is not forced to the target rotation. It just has an angular velocity set that sends it toward the target. If it is interrupted by a collision or some other means, the target will be set, but the object may not reach it.
Params:
rotationTarget: The rotation target.
angularSpeed: The speed at which you want the object to rotate to the target.
autoStop: Whether or not to autoStop upon reaching the taret.
callback: Whether or not to perform a script callback (onRotationTarget()) upon reaching the designated target rotation.
snap: Whether or not to snap the object to the target when it is within margin.
targetMargin: The proximity to the target necessary to qualify as reaching the target.
What do you mean by "replace" the cursor? You mean create a custom cursor graphic and switch it in?
This line can be found in game.cs:
Canvas.setCursor(DefaultCursor);
And the defaultcursor is defined like this in common/gui/cursors.cs:
new GuiCursor(DefaultCursor)
{
hotSpot = "1 1";
renderOffset = "0 0";
bitmapName = "~/gui/images/defaultCursor";
};
So somewhere you can define another cursor with your bitmap of choice and then set it.
Or you might want to do what is mentioned in the mole tutorial, hide the cursor and have a sceneobject follow your cursor around, look at the whackamole tutorial for details.