Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Orientation in 2D
#15
Great news. I now have Curvy working in 100% of my 2D use cases.

Your initial suggestion to just flip the ending CP was ultimately correct. It didn't seem correct at first due to the pooling issue and because flipping is scenario dependent. And then once the pooling issue was addressed, I was already deep in the muck of using interim control points as orientation anchors and procedurally setting their orientations, which caused as many problems as they solved. Backing those things out, using Dynamic Orientation, and finding out WHEN to flip the ending CP was the ultimate answer.

Here it is for anyone who is working in 2D

Code:
public CurvySpline m_TrackSpline;

private List<Vector3> m_ControlPoints = new List<Vector3>();

private void Construct2DSpline() {
//clear previous track
m_TrackSpline.Clear();
m_ControlPoints.Clear();
//do not use pooling until Curvy is updated to refresh the orientation of pooled objects

//fill a list of 2D control point locations specific to your scenario/game

m_TrackSpline.Add(m_ControlPoints.ToArray());

//compare orientation of starting and ending control point to flip ending cp when appropriate to maintain 2D orientation
Vector3 startEuler = m_TrackSpline.ControlPointsList[0].GetOrientationFast(0f).eulerAngles;
Quaternion endRotation = m_TrackSpline.ControlPointsList[m_TrackSpline.ControlPointCount - 1].GetOrientationFast(0f);
Vector3 endEuler = endRotation.eulerAngles;

bool bShouldFlip = false;
if (startEuler.y > 269f) {
if (endEuler.y < 269f) {
bShouldFlip = true;
}
}
else if (endEuler.y > 269f) {
bShouldFlip = true;
}

if (bShouldFlip) {
Quaternion finalTwist = endRotation * Quaternion.Euler(180f, 0f, 0f);
m_TrackSpline.ControlPointsList[m_TrackSpline.ControlPointCount - 1].SetRotation(finalTwist);
}
}

Similar logic might make for a good bool toggle companion to RestrictTo2D

Thanks Aka for all your help and patience!!!
Reply


Messages In This Thread
Orientation in 2D - by Livealot - 07-24-2018, 09:54 PM
RE: Orientation in 2D - by _Aka_ - 07-25-2018, 11:47 AM
RE: Orientation in 2D - by _Aka_ - 07-25-2018, 11:59 AM
RE: Orientation in 2D - by Livealot - 07-26-2018, 03:05 PM
RE: Orientation in 2D - by _Aka_ - 07-26-2018, 04:11 PM
RE: Orientation in 2D - by Livealot - 07-26-2018, 04:41 PM
RE: Orientation in 2D - by _Aka_ - 07-26-2018, 06:10 PM
RE: Orientation in 2D - by Livealot - 07-29-2018, 09:31 PM
RE: Orientation in 2D - by _Aka_ - 07-30-2018, 12:35 AM
RE: Orientation in 2D - by Livealot - 07-30-2018, 04:47 PM
RE: Orientation in 2D - by Livealot - 07-30-2018, 11:27 PM
RE: Orientation in 2D - by _Aka_ - 07-31-2018, 10:13 PM
RE: Orientation in 2D - by Livealot - 08-01-2018, 12:30 AM
RE: Orientation in 2D - by _Aka_ - 08-01-2018, 12:12 PM
RE: Orientation in 2D - by Livealot - 08-01-2018, 08:00 PM
RE: Orientation in 2D - by _Aka_ - 08-02-2018, 10:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Shapes points orientation itsGama 3 8 01-18-2023, 02:51 PM
Last Post: _Aka_
  2d - orientation looping_co 1 5 09-01-2022, 04:17 PM
Last Post: _Aka_
  Spline controller orientation itsGama 4 31 01-24-2022, 06:38 PM
Last Post: _Aka_
  Regarding static orientation mydayz 10 288 12-05-2021, 01:25 PM
Last Post: _Aka_

Forum Jump: