/// <summary> /// Instantiates a Follower with specified object and speed, the rest are default /// </summary> /// <param name="newObject">The GameObject that this Follower will represent</param> /// <param name="newSpeed">The speed this Follower will have</param> public Follower(GameObject newObject, float newSpeed) { followerObject = newObject; pathProgress = 0; behaviour = BasePath.ePathBehaviour.ABSOLUTE; endEvent = BasePath.eEndPathEvent.STOP; speed = newSpeed; relaPos = newObject.transform.position; }
/// <summary> /// Instantiates a Follower with all of the specified parameters /// </summary> /// <param name="newObject">The GameObject that this Follower will represent</param> /// <param name="newPathProgress">Where (from 0-1) the object will start</param> /// <param name="newBehaviour">The following behaviour this Follower will use</param> /// <param name="newEndEvent">The EndPathEvent this Follower will use</param> /// <param name="newSpeed">The speed this Follower will have</param> public Follower(GameObject newObject, float newPathProgress, ePathBehaviour newBehaviour, eEndPathEvent newEndEvent, float newSpeed) { followerObject = newObject; pathProgress = newPathProgress; behaviour = newBehaviour; endEvent = newEndEvent; speed = newSpeed; relaPos = newObject.transform.position; //Saves home position, to be changed to actual relaPos once added to a Path }
public override Vector2 GetWorldPositionViaPathProgress(float pathProgress, ePathBehaviour behaviour) { Vector2 newCoord = (behaviour == ePathBehaviour.ABSOLUTE) ? (new Vector2(0, 0)) : (-FirstPoint); Vector2 lineInfo = findLine(pathProgress); int lineIndex = (int)lineInfo.x; float remainingLength = lines[lineIndex].Length - lineInfo.y; newCoord += lines[lineIndex].beginPoint; float angle = lines[lineIndex].Angle; newCoord.x = newCoord.x + Mathf.Cos(angle) * remainingLength; newCoord.y = newCoord.y + Mathf.Sin(angle) * remainingLength; return(newCoord); }
/// <summary> /// Abstract function that will return the world position based on progress and follow behaviour (relative or absolute) /// </summary> abstract public Vector2 GetWorldPositionViaPathProgress(float pathProgress, ePathBehaviour behaviour);