Author Topic: (Solved?) Setting player pitch (AIConnection setMove speed/units question)  (Read 953 times)

So for reasons that would probably end up being a bit of a long rant, I want to set the amount that a player is looking up/down to match an eye vector that was retrieved separately at a close-to-instant speed, and I was to understand that the only way to do this on the server-side is to have an AIConnection control the player briefly, and use the setMove function of the AIConnection to set its' pitch speed to a certain amount.

The problem is, I am completely at a loss as to what the units are for this function.  I thought I was informed that if you entered ...setMove("pitch",x); it would move at whatever x is per second, but I don't recall what the units were, and trying x at values such as 0.1 still resulted in the player looking all the way down by the end of a second.

Does anyone know exactly what units the variable is for pitch in setMove, such as degrees, radians, or fractions of the total vertical movement range, and whether it's "per second" or some other unit of time?

Thanks for your time.
« Last Edit: February 27, 2012, 10:54:57 PM by []----[] »

There really isn't a way to just snap a few units using the AiConnection method. Doing "pitch",1 would be like using keyboard controls to look up, holding the button down forever.

How fast 1 actually is, well, I have no idea.

Just found out that when I set the pitch speed to mDegToRad(-45) and held it there for 33 milliseconds, I looked upwards (what appears to be) exactly 45 degrees.

This new data basically answers my question, but I'm going to leave the topic unlocked in case anyone has any clarifying/correcting information or I find out that this solution has a bug in it.

Edit: It seems like 33ms will actually sometimes result in it moving twice as much as it should be.  I'm experimenting around with some slightly lower values like 30ms.
« Last Edit: February 27, 2012, 11:58:58 PM by []----[] »

That's some handy information.

Edit: It seems like 33ms will actually sometimes result in it moving twice as much as it should be.  I'm experimenting around with some slightly lower values like 30ms.

This might be caused by the fact that the TorqueScript engine has no threading. How much background processing is going on?

Is this what you are looking for? AI right?

Code: [Select]
function LookAtPlayer(%Player, %Bot)
{
   if(!isObject(%Player))
      return;
     
   if(!isObject(%Bot))
      return;
     
   %y = getWord(%Player.getDataBlock().boundingBox, 1);
   %pos = getWords(%Player.getTransform(), 0, 2);
   %oldPos = %pos;
   %vec = "0 -4 0";
   %vec = MatrixMulVector(%Player.getTransform(), %vec);
   %pos = "0 0 0";
   %pos = VectorAdd(%oldPos, VectorScale(%vec, %y));
   
   %followPos = %pos;
   %pos = getWords(%Bot.getTransform(), 0, 2);
   %vec = VectorSub(%followPos, %pos);
   %len = VectorLen(%vec);
   
   %Bot.setAimLocation(%followPos);
}

That would require the player to be an AiPlayer.

He wants an AiConnection to control a normal Player for a moment, and look a certain amount of degrees.

Why is it not possible to just set which angle you're looking?
It seems kinda dumb to not have a default function for that.