I am currently building a waypoint system with a editor. I have a object WayPoint, and a object Path. Both objects are Serializable.
All waypoints are stored in a array in the object Path. Also each Waypoint object has a array with other waypoints (links). So the game knows where the waypoint is connected to.
So one waypoint object, can have 2 or more references. This is working until I start the project. Then for each references, a new copy of the old waypoint is created. So now I have 2 waypoints instead of one.
Is there a way to make sure that there will be only one waypoint object for 2 or more references/variables?
using UnityEngine;
using System.Collections;
using System;
namespace AI {
[System.Serializable]
public class Paths : MonoBehaviour {
public Waypoint[] wayPoints = new Waypoint[0];
}
}
using UnityEngine;
using System.Collections;
using System;
namespace AI {
[System.Serializable]
public class Waypoint {
public Vector3 position;
public Waypoint[] links = new Waypoint[0];
public Waypoint(Vector3 position) {
this.position = position;
}
}
}
All the values (array and position) are set by the editor. There can be multiple waypoints but only one path object.