November 2018
Beginner
246 pages
5h 23m
English
The TestCode class will use the AStar class to find the path from the start node to the target node, as shown in the following code from the TestCode.cs file:
using UnityEngine;
using System.Collections;
public class TestCode : MonoBehaviour {
private Transform startPos, endPos;
public Node startNode { get; set; }
public Node goalNode { get; set; }
public ArrayList pathArray;
GameObject objStartCube, objEndCube;
private float elapsedTime = 0.0f;
//Interval time between pathfinding
public float intervalTime = 1.0f;
In the preceding snippet, we first set up the variables that we need to reference. The pathArray variable stores the nodes array that's returned from the AStar FindPath method.
In the following code block, we ...
Read now
Unlock full access