Here's a simple example of how to rotate an object's mesh when you press a key...
First, in the opr (see the comments for details)...
LoadObject robot.3ds
ObjectName robot
ControllerType Scripted
ControllerSetting ScriptFile robot.gsl
CastShadow 1
ReceiveShadows 1
VisibleInReflections 0
EnableLightMap 0
CastLightMapShadow 0
ClearRoadConnectors 1
LoadObject robotArm.3ds // load the second object
ObjectName arm1 // give it a name so we can create a handle to it in our script
ObjectParent robot // declare the main mesh the parent
ObjectPosition 0.0000 1.0000 0.5000 // adjust the position, if necessary
Then in the gsl (again, see the comments and also note that I've stripped all but the relative commands out of this script)...
//At the top, in the constants / variables section...
ObjectMesh@ arm1; // this is going to be the handle to our mesh
Vector arm1Rot; // this will be used for the mesh's rotation
float firePressed = 0; /*// this will be used to determine if the LMB is pressed (note, this is probably already declared if you're modifying an existing GC player script) */
//In the initialize section...
void Initialize( Object@ object)
{
@arm1 = object.GetMesh( "arm1"); // create the actual handle to the mesh
}
// In the Handle Event section...
//"Fire" must be mapped in Input.cfg (probably already is)
bool HandleEvent( Object@ object, const String& in event, GameEventParams@ params)
{
if (event == "Input")
{
if (params.stringValue == "Fire")
{
firePressed = params.floatValue; // set the float firePressed to equal the value of the input
return true;
}
return false;
}
return false;
}
// In the dynamic events section...
void DynamicsAdvance( Object@ object, float seconds)
{
if(firePressed > 0.5)
{
arm1Rot = arm1.GetRotationEuler(); // set our variable to equal the current rotation of the mesh
arm1.SetRotationEuler(Vector(arm1Rot.x, arm1Rot.y + 1, arm1Rot.z)); // set the rotation of the mesh
}
}
Again, that's a really simple example, but that should get you started in the right direction. You could easily setup a second button to have it rotate in the opposite direction as well.