Li Song, on 09 May 2014 - 02:53 AM, said:
I was directed here from reddit. I'm developing the Li Song Mechlab software (
http://mwomercs.com/...g/page__st__100) and I have a question about mech movement. What is the correct way of calculating a mech's turning speed? I discussed this with Smurfy (
https://github.com/E...lsml/issues/226) and we're currently using a formula from an old, discontinued mechlab called mechromancer(?) which is: "enginerating / mechtons * 360/31.4". I'm interested to know if there is a value in the .mdf files I could use instead of 360/31.4.
This is a bit complicated. I've just looked through all of the code again to see where all the config values come from, and indeed the mdf turn parameters and the engine rating are used. Beyond that, here are some of the factors:
- Engine rating gets divided by mechs max tonnage to calculate an effective engine rating for that mech.
- There are separate turn speeds for mech legs, upper torso pitch, upper torso yaw, arm pitch, and arm yaw
- The mech leg turn speed is affected by your engines current power output* when actually in-game, the higher your throttle, the faster you can turn
- The scaling of that mech leg speed is done using a three-point linear interpolation, controlled by the factors:
TurnLerpLowRate
TurnLerpMidRate
TurnLerpHighRate
TurnLerpLowSpeed
TurnLerpMidSpeed
TurnLerpHighSpeed
- Several mdf parameters are converted from degrees to radians, and then multiplied by engine effective rating and skill-tree bonuses
The following parameters are directly converted from degrees to radians ( * (Pi / 180)) in-code:
TorsoTurnSpeedPitch
TorsoTurnSpeedYaw
MaxTorsoAnglePitch
MaxTorsoAngleYaw
MaxArmRotationPitch
MaxArmRotationYaw
ArmTurnSpeedPitch
ArmTurnSpeedYaw
MaxFreeLookPitch
MaxFreeLookYaw
So I think in general, the formula you are looking for is <mdf value> * (Pi / 180) * (<engine rating> / <mech max tonnage>) * <skill tree fudge factor>
That covers pretty much everything except the leg turn speed, which is affected by throttle rate and a more complicated multi-lerp implementation to determine actual turn speed.
Now, to understand the leg turn rate requires those 6 factors I mentioned earlier: TurnLerpLowRate, TurnLerpMidRate, TurnLerpHighRate and TurnLerpLowSpeed, TurnLerpMidSpeed, TurnLerpHighSpeed. These values are specified in radians, not degrees.
Lets define some notation to make this easier to read/write:
TurnLerpLowSpeed = inLow
TurnLerpMidSpeed = inMed
TurnLerpHighSpeed = inHigh
TurnLerpLowRate * (<engine rating> / <mech max tonnage>) = outLow
TurnLerpMidRate * (<engine rating> / <mech max tonnage>) = outMed
TurnLerpHighRate * (<engine rating> / <mech max tonnage>) = outHigh
Throttle = x
The throttle is used as an interpolation value in the following way:
if (x <= inLow)
{
return outLow;
}
else if (x > inLow and x <= inMed)
{
float factor = ((x - inLow) / (inMed- inLow));
return outLow + factor * (outMed - outLow);
}
else if (x > inMed and x <= inHigh)
{
float factor = ((x - inMed) / (inHigh - inMed));
return outMed + factor * (outHigh - outMed);
}
else
{
return outHigh;
}
To get turn speed for any given throttle setting should involve using that above function. Also a disclaimer; I put this together pretty quickly, so there could very well be errors. Don't take this as 100% completely confirmed.
Hopefully that helps!
* The actual throttle value used in-game maps to engine output power, so this input varies with hill climb factor, how long the mech has been accelerating, whether or not you're running into a wall, etc..
edit: formatting
edit2: fixes found by LiSong