- Home /
Position Objects around point[With picture]
Hey,
I am working on an RTS game and things are going really well. On big problem is, that when i want units to walk in range (see code below), they all walk on the exact same position. I do know how to handle formations, but only line formations, I dont know how to do this with a circle. On the left side of my picture you can see how my Objects behave. The red dots are ordered to attack the black one but are out of range. They walk into range (blue circle) by following the green line. Thats okay for one obeject, but if there are more then one object they start bumping into each other. I want them to position themselves along the circle (right side of the picture) pseudocode is fine !
![http://i.imgur.com/nTrlJxh.jpg][1] [1]: http://i.imgur.com/nTrlJxh.jpg
public void Attack(GameObject Attacktarget)
{ if(Vector3.Distance(Attacktarget.transform.position,transform.position)<=(range+0.5))
{
Debug.Log ("In Range of Target");
}
else
{
Debug.Log ("Out of Range");
Vector3 Dist =Attacktarget.transform.position - transform.position;
Posi.Navi.SetDestination(Attacktarget.transform.position-(range*Dist.normalized));
}
Your answer
Follow this Question
Related Questions
Make a navmesh object start moving in a circle around an object 0 Answers
RTS health bars 2 Answers
Change position relative to object 3 Answers