-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
5,213 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"version": "1.0", | ||
"components": [ | ||
"Microsoft.VisualStudio.Workload.ManagedGame" | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.AI; | ||
public class MoveToTarget : MonoBehaviour | ||
{ | ||
public Transform target; | ||
public Transform agentPos; | ||
NavMeshAgent agent; | ||
[SerializeField] | ||
Vector3 distance; | ||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
agent = GetComponent<NavMeshAgent>(); | ||
agentPos = GetComponent<Transform>(); | ||
agent.destination = target.transform.position; | ||
} | ||
void Update() | ||
{ | ||
distance = target.transform.position - agentPos.transform.position; | ||
if (distance.x < 5 || distance.z < 5 && distance.x > 5 || distance.z > 5) | ||
{ | ||
agent.destination = target.transform.position; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.