Skip to content

Instantly share code, notes, and snippets.

@TORISOUP
Last active August 29, 2015 14:17
Show Gist options
  • Save TORISOUP/0a07ae5f5c29bef77068 to your computer and use it in GitHub Desktop.
Save TORISOUP/0a07ae5f5c29bef77068 to your computer and use it in GitHub Desktop.
var enemyNames = Enemys.GetComponentsInChildren<Enemy>()
.Where(x => x.HP > 0)
.Where(x =>
{
var enemyPos = x.transform.position;
var playerPos = player.transform.position;
return Vector3.Distance(enemyPos, playerPos) <= 10;
})
.Where(x =>
{
var playerPos = player.transform.position;
var enemyPos = x.transform.position;
var playerDirection = player.transform.forward;
var toEnemyDirection = enemyPos - playerPos;
var angle = Vector3.Angle(playerDirection, toEnemyDirection);
return angle < 30.0f;
})
.OrderBy(x =>{
var enemyPos = x.transform.position;
var playerPos = player.transform.position;
return Vector3.Distance(enemyPos, playerPos);
})
.Select(x => x.ScreenName);
var enemyNames = Enemys.GetComponentsInChildren<Enemy>()
.Where(x => x.HP > 0)
.Where(x => Vector3.Distance(x.transform.position, player.transform.position) <= 10)
.Where(x => Vector3.Angle(player.transform.forward,
x.transform.position - player.transform.position) < 30.0f)
.OrderBy(x => Vector3.Distance(x.transform.position, player.transform.position))
.Select(x => x.ScreenName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment