- Home /
C# boids separation help
hey pals can someone help me to translate the code of this into c# for unity? i have been trying like mad but its kind of hard to do when you know little about c#, please help if u can!
public function computeAlignment(myAgent:Agent):Point
{
var v:Point = new Point();
var neighborCount = 0;
for each (var agent:Agent in agentArray)
{
if (agent != myAgent)
{
if (myAgent.distanceFrom(agent) < 300)
{
v.x += agent.velocity.x;
v.y += agent.velocity.y;
neighborCount++;
}
}
}
if (neighborCount == 0)
return v;
v.x /= neighborCount;
v.y /= neighborCount;
v.normalize(1);
return v;
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
A real head-scratcher 0 Answers
Object from list in scriptableobject in list 0 Answers
Google Play Service LogIn Problem 0 Answers