- A* version: 5.4.4
- Unity version: 6.0.38f1
When spawning a character, I want to spawn it in a location that doesn’t overlap with the radius of another character’s followerEntity.
Since the character doesn’t have a collider, I can’t use Physics2D.OverlapCircle.
Is there a way to check if a followerEntity exists within a certain radius of a specific location, similar to Physics2D.OverlapCircle?
I think you just want
// 'follower' being the Follower that already exists
float distance = Vector3.Distance(myDesiredPosition, follower.position);
if (distance > follower.radius){
// Success!!
}
If you want to check for a direct overlap. You can also add spacing this way.
Is there any way to check without access to the objects of the spawned characters?
Hi
If you use local avoidance, you could likely use:
var simulator = RVOSimulator.active.GetSimulator();
var rwlock = simulator.LockSimulationDataReadOnly();
rwlock.dependency.Complete();
if (simulator.quadtree.QueryArea(somePosition, someRadius) == 0) {
// Empty
}
rwlock.UnlockAfter(default);
(I haven’t tested the code above, but I think it should work)
I tried it but sadly it doesn’t work