void Start() { //create the game object that will hold the spline plus component and catch the SPData to use further SPData = SplinePlusAPI.CreateSplinePlus(Vector3.zero); //create the 2 nodes var node1 = SplinePlusAPI.CreateNode(SPData, new Vector3(10, 0, 0)); var node2 = SplinePlusAPI.CreateNode(SPData, new Vector3(-10, 0, 0)); //connect the 2 node SplinePlusAPI.ConnectTwoNodes(SPData, node1, node2); //change the node points to get the oval shape, // just copy the values from the editor example it's easier this way node1.Point1.position = new Vector3(10, 0, Power); node1.Point2.position = new Vector3(10, 0, -Power); node2.Point1.position = new Vector3(-10, 0, Power); node2.Point2.position = new Vector3(-10, 0, -Power); //set looped to true to close the shape SPData.IsLooped = true; //trigger a spline plus update SPData.SplinePlus.SplineCreationClass.UpdateAllBranches(SPData); }
public void Start() { SPData = SplinePlusAPI.CreateSplinePlus(Vector3.zero); var pathPoint1 = SplinePlusAPI.CreateNode(SPData, new Vector3(0, 0, 0)); var pathPoint2 = SplinePlusAPI.CreateNode(SPData, new Vector3(10, 0, 0)); var pathPoint3 = SplinePlusAPI.CreateNode(SPData, new Vector3(10, 0, 10)); var pathPoint4 = SplinePlusAPI.CreateNode(SPData, new Vector3(0, 0, 10)); SplinePlusAPI.ConnectTwoNodes(SPData, pathPoint1, pathPoint2); SplinePlusAPI.ConnectTwoNodes(SPData, pathPoint2, pathPoint3); SplinePlusAPI.ConnectTwoNodes(SPData, pathPoint3, pathPoint4); SplinePlusAPI.ConnectTwoNodes(SPData, pathPoint4, pathPoint1); SplinePlusAPI.SmoothAllSharedNodes(SPData, 0.5f); FollowerSettings(SPData); }
public void CreatePath() { var SplinePlus = SplinePlusAPI.CreateSplinePlus(Vector3.zero); Node pathPoint1 = new Node(); Node pathPoint2 = new Node(); for (int i = 0; i < Points.Count - 1; i = i + 2) { if (Points[i] == null || Points[i + 1] == null) { DestroyImmediate(SplinePlus.DataParent); return; } pathPoint1 = SplinePlusAPI.CreateNode(SplinePlus, Points[i].transform.position); pathPoint2 = SplinePlusAPI.CreateNode(SplinePlus, Points[i + 1].transform.position); SplinePlusAPI.ConnectTwoNodes(SplinePlus, pathPoint1, pathPoint2); } SplinePlusAPI.SmoothAllSharedNodes(SplinePlus, Radius); }