- Home /
RTS units team
Hi programmers,
How could I implement that each enemy is checking each other enemy by distance (multiple gameobjects) when the leader has reached it's target and then basically what I need is that it reforms itself to a team.
Thanks,
HelloIam41
Answer by nikroth · Jan 09, 2014 at 10:50 AM
Make the units to share the same squadID to know which units are together.
When you select desired moce position set it in a property.
Add a trigger to the units (read a tutorial how to make triggers) and when the trigger fires reset the property above and after that regroup the units around this point.
(if you have a leader unit then you may add the trigger only to the leader)
Answer by helloiam · Jan 09, 2014 at 11:19 AM
That is not what I need what I have is that one leader is moving to my mouse position and the others are following him so when they follow him and I do a distance check between the team and the leader they will all stop at the same position. What I need is that they check each other and reform themself as a square when they reached their destination instead of stopping at the same position or jumping on each other.
HelloIam41
Add the trigger to the captain In the trigger event add a code which calculates how many rows and columns of units u need and then give the units their new coordinates
if you have 8 units and you want them in 2 rows set the point of the first unit the second one is margin + unit.width and so on and u give these new calcualted positions as their new positions (not to go on top of the captain)
Your answer
Follow this Question
Related Questions
how do i make teams for a rts game 1 Answer
Half-issue with find enemy script 1 Answer
How do i have AI objects have teams and attack when in range 3 Answers
RTS camera help 1 Answer