Forked from unitycoder/gist:9a67e9bd559fb622d0e2
Last active
August 29, 2015 14:23
-
-
Save JT5D/a80c18d30371e8e2cc3e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Linq; | |
| .. | |
| // get list of objects with tag "Player" | |
| GameObject[] gos = GameObject.FindGameObjectsWithTag("Player"); | |
| // get closest transform from gos[] array, into target variable, as transform object | |
| var target = gos.OrderBy(go => (transform.position - go.transform.position).sqrMagnitude).First().transform; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment