/// <summary> /// Affect the referenced potential field with a force. /// Adds a weight to the current position to avoid enemies colliding into eachother paths. /// Also generates an small trail to avoid making the enemy go back the same way it came. /// </summary> /// <param name="pf">The potential field to affect.</param> public void GenerateForce(ref PotentialFieldScriptableObject pf) { for (int i = 0; i < prevPosHistory.Length; i++) { pf.AddCellValue(prevPosHistory[i].x, prevPosHistory[i].y, -10); } pf.AddCellValue(currentPos.x, currentPos.y, -1024); pf.AddCellValue(currentPos.x + targetPos.x, currentPos.y + targetPos.y, -1024); }
/// <summary> /// Affect the referenced potential field with a force. /// Adds a small weight to the current position to avoid enemies colliding into eachother paths. /// </summary> /// <param name="pf">The potential field to affect.</param> public new void GenerateForce(ref PotentialFieldScriptableObject pf) { pf.AddCellValue(pf.LocalPosX(transform.position), pf.LocalPosY(transform.position), 2); }