Game Development Community

Accessing a Units net movement speed?

by Stephen Zepp · in RTS Starter Kit · 11/11/2004 (9:20 pm) · 5 replies

I'm playing around with making all units that are in a formation move at the same speed (slowest unit in the formation's speed).

I've added mMoveSpeedLimit to RTSUnit, pack/unpacked it (I think properly), and modified RTSUnit::processTick() to set the v like so:
v = getMin( (mMoveSpeedLimit > 0.0f) ? mMoveSpeedLimit : 5000.0f,
                           data->mMoveSpeed * mNetModifier.mMoveSpeed) * TickSec;
            else
              v = getMin( (mMoveSpeedLimit > 0.0f ) ? mMoveSpeedLimit : 5000.0f, mMoveVelocity) * TickSec;

The intended purpose of that code is to use the normal calculations if mMoveSpeedLimit is 0.0f, otherwise cap it at mMoveSpeedLimit.

I wrote access/console methods to allow script to find the lowest mMoveSpeed of a selection, and as I issue each move command I set the mMoveSpeedLimit to that value.

What I don't quite understand is I guess the use of mMoveSpeed, as opposed to data(block)->mMoveSpeed. It appears that RTSUnit->mMoveSpeed is clamped between 0.0f and 1.0f.

Is there a reason to clamp it, and why do we refer to the datablock's movement speed instead of the RTSUnits mMoveSpeed when performing the move?

#1
11/11/2004 (9:58 pm)
I got this working (configurable on the move call via script), and will post a set of changes tomorrow (need sleep!).

I'm still curious however what RTSUnit->mMoveSpeed is intended for, since it's clamped down so tightly. As far as I can tell, the movement code only uses the mMovementSpeed (modifed my the NetModifier.moveSpeed), so I think I'm missing why RTSUnit has the var as well.
#2
11/12/2004 (10:15 am)
It might be a holdover from the AI code, or maybe it's meant to let you scale down unit speeds... I'll add it to my list of Stuff To Look At. Good eye! :)
#3
11/12/2004 (11:19 am)
Yeah, I was treating my mMoveSpeedLimit the same in all ways as mMoveSpeed. After I triple checked and found out that mMoveSpeed wasn't actually used anywhere, I treated mMoveSpeedLimit as parallel in function to mDataBlock->mMoveSpeed (let it be bigger than 1.0f), and it worked like a champ.

Not only are my various squads in formations now, but they even stay in formation as they move, instead of random paths and speeds to their individual destinations...quite fun!
#4
11/12/2004 (11:58 am)
Coolness Stephen. :)

Yes, RTSUnit.mMoveSpeed is left over cruft. Woops! You could either remove it, or make it useful by relying on it instead of the db value. If it's removed, it will save a very slight bit of network traffic. If it's made useful, you can easily set individual unit speeds (without having to use a modifier). I'd probably just remove it myself.

Re: your formation stuff... great! Thanks for posting it in here too, I love to see sharing like that. Hopefully we'll get a whole bunch of this kind of stuff going.
#5
11/17/2004 (3:50 pm)
Ok, I blasted it. Thanks for looking into this, guys. The moveSpeedLimit is a great idea, but I don't really want to introduce new functionality in this release, mostly fix brokenness. Next release, though...