0

I'm trying to make a Seek and Flee behavior for an AI project. I tried putting the algorithm but I get this error. I'm not getting why it is not working and I could use some guidance.

Here is the segment of code that isn't working:

public Vector2 Seek(Vector2 source, Vector2 target, float maxAccel)
{
     Vector2 acceleration = (target - source).Normalize() * maxAccel;
     return acceleration;

}
zig
  • 3
  • 1

1 Answers1

1

The documentation for the Normalize() function says it returns a void, but you're trying to assign it to a variable of type Vector2. You'll probably want to use this variant of the Normalize() function as follows:

Vector2 acceleration = Vector2.Normalize(target - source) * maxAccel;

I assume that both target and source are of type Vector2 and maxAccel is a scalar value.

Reticulated Spline
  • 1,892
  • 1
  • 18
  • 20