Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
To dynamic generate the connection between paths
#2
okay, I found the function to generate curve at runtime..
here is the shadow code that I think will work

Code:
Transform m_Ship = null; // assume we got this
CurvySpline curveA = null; // assume we got this
CurvySpline curveB = null; // assume we got this

float startTF = curveA.GetNearestPointTF(m_Ship.position, Space.World);
Vector3 startPoint = curveA.GetApproximation(startTF, startTF, true, Space.World)[0]; // Huh ? how to get the closer sample point ?
Vector3 startTangent = m_Ship.forward * 2f; // bias
           
float endTF = curveB.GetNearestPointTF(startTangent, Space.World);
Vector3 endPoint = curveA.GetApproximation(endTF, endTF, true, Space.World)[0];
Vector3 endTangent = curveA.GetOrientationFast(endTF, false, Space.World) * Vector3.forward;

var curve = CurvySpline.Create();
var start = curve.Add(startPoint, Space.World);
start.HandleOut = start.transform.InverseTransformPoint(startTangent); // is that the right way to convert local space ?
var end = curve.Add(endPoint, Space.World);
end.HandleIn = endTangent;


so... is that all I need ?
Question about "curveA.GetApproximation()" I expect will get the closest point instead of array of Vector3, am I doing it wrong ?
since I got startFT from "GetNearestPointTF"
... continue testing.
Reply


Messages In This Thread
RE: To dynamic generate the connection between paths - by Canis - 08-07-2020, 08:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
Thumbs Up Can't delete connection lacota 3 6 03-16-2024, 11:34 AM
Last Post: _Aka_
  Cant Generate Meshes At Runtime alms94 5 22 01-26-2024, 11:27 AM
Last Post: _Aka_
Lightbulb Junction & Connection Navigation System Design SAMYTHEBIGJUICY 4 13 11-27-2023, 01:04 PM
Last Post: _Aka_

Forum Jump: