Game Development Community

next headache : %obj.setImageScriptAnimPrefix

by Grey9999 · in Torque 3D Professional · 03/12/2013 (3:37 am) · 3 replies

I can't get this to work at all. According to the documentation %obj.setImageScriptAnimPrefix( 0, "aim");
without any other prefixes should cause it to use animations like "aim_root, aim_run" etc....
how do you use this thing? These functions are called by some of my weapons states (which are triggered by the altfire trigger, in this cause mouse 2 being held down);



function WeaponImage::onReady(%this, %obj, %slot)
{
   echo( "Ready!");
   
   %obj.setImageScriptAnimPrefix( 0, "");
 
   ServerConnection.zoomed = false;
   setFov(ServerConnection.getControlCameraDefaultFov());
   Reticle.setVisible(false);
   zoomReticle.setVisible(false);
   ppOptionsUpdateDOFSettings();
}
function WeaponImage::onAim(%this, %obj, %slot)
{
   $Player::CurrentFOV = 65;
   $Player::ZoomSpeed = 500;
  
   %obj.setImageScriptAnimPrefix( 0, "aim");
   
   ServerConnection.zoomed = true;
   setZoomSpeed($Player::ZoomSpeed);   
   setFov($Player::CurrentFOV);
   Reticle.setVisible(true);
   zoomReticle.setVisible(false);
   echo( "Aiming!" );      
      
   //DOFPostEffect.setAutoFocus( true );
   //DOFPostEffect.setFocusParams( 0.5, 0.5, 50, 500, -5, 5 );
   //DOFPostEffect.enable();
   
}

#1
03/12/2013 (6:44 am)
Hmm not sure but doesn't look like %obj.setImageScriptAnimPrefix( 0, "aim"); should be in those functions for the fact that %obj isn't referenced to any thing I don't believe so you might have to find another function that %obj is your player.

I could be wrong though
#2
03/12/2013 (8:05 am)
@Grey9999:
It looks like the string passed into setImageScriptAnimPrefix() needs to be a network string. This is a special string type that is converted into a number so it may be passed between the client and server with minimal bandwidth. Unfortunately, the docs for this method don't point this out.

Here is how it is used when the player changes poses:

function Armor::onPoseChange(%this, %obj, %oldPose, %newPose)
{
   // Set the script anim prefix to be that of the current pose
   %obj.setImageScriptAnimPrefix( $WeaponSlot, addTaggedString(%newPose) );
}

To convert an ordinary string to a networked string just call addTaggedString() on it.

And if you're using the standard player scripts, the Armor::onPoseChange() method may be overriding your own image prefix as you can see in the code above.

I hope that helps.

- Dave
#3
03/12/2013 (10:53 am)
Ok changed it to a tagged network string. Also commented out Armor::onPoseChange. Still no luck.

How would I make sure that %obj is my player??