Original Post
I'm making an RTS game and i want to be able to have group formations i have written the code under and it works when the Angle is 0 and 180 but does for any other angle. The angle determines what way the formation faces. I'm pretty sure it's to do with the Z value. Can someone please tell me how i would change it to make it work. I've tried different ways but i can't seem to get it to work. void CUnitController::GetDestinations(CVector MouseClickedAt) { int RowSize = 0; double Radius = 0; double Diameter = 0; int Counter = 0; int NoSelectedUnits = 0; double Angle = 0; int RowCounter = 0; // Get the biggest radius for( ulint i = 0; i < MaxSize; i++ ) if(IsFull && Units->IsSelected()) { if(Units->Radius > Radius) Radius = Units->Radius; NoSelectedUnits++; } RowSize = int(sqrt(NoSelectedUnits)*1.5); if(NoSelectedUnits < RowSize) RowSize = NoSelectedUnits; Diameter = 2*Radius; double SinTemp = sin(Angle + (PI/2)); double CosTemp = cos(Angle); for( ulint i = 0; i < MaxSize; i++ ) if(IsFull && Units->IsSelected()) { if(Units == NULL)throw "Problem In CUnitController Class"; double X = MouseClickedAt.x + (SinTemp*((Counter-(RowSize/2))*Diameter)); double Z = MouseClickedAt.z + (CosTemp*Diameter*RowCounter); Units->SetDestination(CVector(X,MouseClickedAt.y,Z)); Counter++; // If Counter = RowSize move down to next row if(Counter == RowSize) { RowCounter++; Counter -= RowSize; } } }