Skip to content

Instantly share code, notes, and snippets.

@haramakoto
Created December 8, 2022 20:48
Show Gist options
  • Save haramakoto/250b34419af5ea1673ebff9ec54e446a to your computer and use it in GitHub Desktop.
Save haramakoto/250b34419af5ea1673ebff9ec54e446a to your computer and use it in GitHub Desktop.
Linqを用いて一番近いオブジェクトを取り出す
using System.Linq;
List<Transform> targetList;
Transform nearestTrans = targetList.OrderBy( x => (x.position - this.position).magnitude).First();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment