Hi,
The player can get on top of rocks or other things in my game and I want to detect when that happens. Note that this code is only called when the enemy couldnt reach the player (Im using behavior trees and this is a separate task from the Move).
// Update loop
_astarAi.destination = _player.position;
_astarAi.SearchPath();
if (_richAi.reachedEndOfPath)
{
Debug.Log("Cant reach player");
return TaskStatus.Running;
}
return TaskStatus.Success;
This works and if I jump from the rock and start moving the enemy will start following me again, the problem is when I land very close to the enemy, and _richAi.reachEndOfPath still returns true even though Im in front of the enemy.
I have tried doing this, but still it cant detect when the player jumps from the rock and lands right in front of the enemy, do you have any ideas what else I can try? Also the Y position of the enemy and the player have a difference, maybe there is another way to better solve this problem?
_astarAi.destination = _player.position;
_astarAi.SearchPath();
if (_astarAi.reachedDestination)
{
Debug.Log("Reached player");
return TaskStatus.Success;
}
if (_astarAi.reachedEndOfPath)
{
Debug.Log("Cant reach");
return TaskStatus.Running;
}
return TaskStatus.Success;