Game Development Community

Unit Speed

by Richard Van Stone · in RTS Starter Kit · 02/05/2006 (12:57 pm) · 4 replies

I just purchased the rts kit this weekend so I'm slowly reading through the files so please bear with me if this has already been discussed and I just haven't found the answer yet. I'd appreciate any links/help that can be offered.

What I'm trying to find out is if there is a way to compute a 'unit speed' based off of the individual members of a unit. What I'm basically trying to do is make the whole unit move at the rate of the slowest unit member. In my game I have unit members that have 0 movement unless they're being carried so I'm wondering if this is already implemented or would I have to implement it myself.

Rich

ps I just remembered this question... I know you're suppossed to be able to have one unit attack a whole different unit but I couldn't get this done. If I clicked on a single member of a seperate unit....my attacking unit only attacked that character. How do you get them to charge a whole unit?

#1
02/05/2006 (1:01 pm)
For the first question, we called it "formation movement", and it can be found Here.

The second question is more complex, because the server has no real concept of units as a group of multiple RTSUnits...in other words, a squad. Squad information is only semi-kept on each client, and only for their clients, and that's only for when you make a "quick selection key", by hitting Cntrl-#, where # is the number you want to assign to that group. Again, this is simply a user interface enhancement, and the server itself has no way of knowing which "squad" a particular unit is in.
#2
02/05/2006 (1:23 pm)
Wow that was a quick response. So I assume then, in regards to the second question, that once I designate a target that I would have to alter the ai code to sweep the area and see if there's another enemy unit...if so move on and attack that one?
#3
02/05/2006 (7:24 pm)
Nevermind that last post I came up with several other possible solutions.
#4
02/06/2006 (1:27 am)
Yes, doing a container ray cast would be a quick solution for this. When they lose their aimObject for whatever reason, have them do a scan and see if they can find another.

I would suggest that you be careful however just how much you want them to do, and how often--with hundreds of units doing searches for new targets every tick, your system risks bogging down quite quickly. My project did implement an auto-attack functionality for enemies and it worked quite well with even a couple of hundred units, but it was done in the source as part of RTSUnit::processTick(), so was faster than using script.