Line of sight for enemy

This commit is contained in:
2024-09-04 17:49:40 -07:00
parent 3dffa12eb8
commit d24b28acd5
5 changed files with 32 additions and 3 deletions

View File

@@ -21,6 +21,12 @@ namespace GameJamDungeon
enemy.LookAt(new Vector3(gameRepo.PlayerGlobalPosition.Value.X, enemy.GlobalPosition.Y, gameRepo.PlayerGlobalPosition.Value.Z), Vector3.Up);
return ToSelf();
}
if (enemy.GlobalPosition.DistanceTo(gameRepo.PlayerGlobalPosition.Value) > 20f)
{
return To<Idle>();
}
enemy.NavAgent.TargetPosition = gameRepo.PlayerGlobalPosition.Value;
var nextPosition = enemy.NavAgent.GetNextPathPosition();
var lookAtPos = enemy.NavAgent.GetNextPathPosition();