unity calculate path
// ShowGoldenPath
using UnityEngine;
using UnityEngine.AI;public class ShowGoldenPath : MonoBehaviour
{
public Transform target;
private NavMeshPath path;
private float elapsed = 0.0f;
void Start()
{
path = new NavMeshPath();
elapsed = 0.0f;
} void Update()
{
// Update the way to the goal every second.
elapsed += Time.deltaTime;
if (elapsed > 1.0f)
{
elapsed -= 1.0f;
NavMesh.CalculatePath(transform.position, target.position, NavMesh.AllAreas, path);
}
for (int i = 0; i < path.corners.Length - 1; i++)
Debug.DrawLine(path.corners[i], path.corners[i + 1], Color.red);
}
}
Also in C#:
- c# initialize array
- uncaught syntaxerror invalid or unexpected token unity webgl
- isGrounded script for copy
- out parameters c#
- eventos c#
- set decimal point c#
- how to flip selection in aseprite
- cc# sort list with list if ids
- @Html.ActionLink
- c# switct case
- devexpress objectspace to session
- unity face direction of movement
- c# print expression tree
- c# copy file
- unity c# public all codes
- asp.net core mvc not triggering client side validation
- c# datetime dd/mm/yyy hh:mm:ss
- console application in c# ms crm
- C# invoke
- c# create a text file
- c# get current directory xamarin
- how to use variables in c#
- unity get velocity of gameobject
- unity particle system color