Is there any way to calculate a path base on agent’s radius?
For example,I have two agents with different size.They start from a same position and also end with a same one.But because they have different sizes,so they get different paths.
Hi,
I found a way to solve my problem.
I created two RecastGraph and set graph mask to each agent.
But I got a new problem.
Now I use Seeker,RichAI and CharacterContoller.
Set target to each agent and set Repeatedly true.
Also I created a new script.
using UnityEngine;
using System.Collections;
using Pathfinding;
public class AStarTest : MonoBehaviour
{
public Transform target;
[SerializeField]
private int _graphMask;
private Seeker _seeker;
private Path _path;
private RichAI _richAi;
void Awake()
{
_seeker = GetComponent<Seeker>();
_richAi = GetComponent<RichAI>();
}
// Use this for initialization
void Start ()
{
_path = _seeker.StartPath(transform.position, target.position, OnPathComplete, 1 << _graphMask);
}
// Update is called once per frame
void Update ()
{
if (_path.error) _path = _seeker.StartPath(transform.position, target.position, OnPathComplete, 1 << _graphMask);
}
public void OnPathComplete(Path p)
{
Debug.Log("Yay, we got a path back. Did it have an error? " + p.error);
}
}
If I don’t use Update the StartPath in Start will return a failed path and agents don’t move.
Even though I Update StartPath it return failed path sometimes.
Now I have no idea about this problem.Do I need to Update StartPath when I set Repeatedly true?
Hey,I found your fantasy examples!
I think I can learn something from those examples.
Hi
Yeah, creating multiple graphs is the way to go.
You might be able to cheat a bit by using the Radius Modifier, but that solution will be a bit fragile.