Timeline for How do I get an NPC to follow the player(and stop when it gets within range)
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 16, 2020 at 10:15 | history | edited | CommunityBot |
Commonmark migration
|
|
Feb 8, 2019 at 19:51 | comment | added | BrianH | @CandidMoon Great resource, hadn't realized they provided the source for the native implementations as well - thanks! | |
Feb 8, 2019 at 19:49 | comment | added | Candid Moon _Max_ |
@BrianH Vector3.Distance(transform.position, friend.position) < stopRange == (transform.position - friend.position).magnitude < stopRange . You can see native code for Vector3.Distance here: github.com/Unity-Technologies/UnityCsReference/blob/master/…
|
|
Feb 8, 2019 at 15:02 | comment | added | BrianH | Really? Neet trick - TIL! | |
Feb 8, 2019 at 15:00 | comment | added | DMGregory♦ | @BrianH that is indeed shorter, though it does entail an unnecessary square root. ;) | |
Feb 8, 2019 at 14:59 | comment | added | BrianH |
+1 The distance check at the end could be simplified with isNearPlayer = (Vector3.Distance(transform.position, friend.position) < stopRange)
|
|
Feb 8, 2019 at 2:59 | history | answered | DMGregory♦ | CC BY-SA 4.0 |