Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question (SOLVED) transformPoint(Spline.EvaluatePosition(T)) does not align with spline.

Discussion in 'Scripting' started by DanVioletSagmiller, Aug 28, 2023.

  1. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    203
    I'm using Unity Splines 2.3.0 on Unity 2022.3.7 - I have a SplineContainer, which I have it evaluate a position on the Spline via Evaluate Position. I assume that is in local space, so I transformPoint with the transform on the same game object with the spline. Despite all this, the positions I get are not accurate. Its hard to see in the image, but there are a series of red dots that the red arrows point at. It matches the spline, but its offset by position only.

    Code (CSharp):
    1.             while (duration < 1f)
    2.             {
    3.                 Positions.Add(
    4.                     _Spline.transform.TransformPoint(
    5.                         _Spline.EvaluatePosition(
    6.                             duration)));
    Any ideas of what I should try or what I might be doing wrong?


    upload_2023-8-28_10-31-46.png
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,882
    What if you don't
    Transform.TransformPoint
    it? It might be that it's actual world coords.

    Check the source code as well.
     
    DanVioletSagmiller likes this.
  3. DanVioletSagmiller

    DanVioletSagmiller

    Joined:
    Aug 26, 2010
    Posts:
    203
    Turns out that was it. I put an offset, and found I was closing in on 0-transform.position (position being the only transform operation happening) Its working now: - Thanks!

    upload_2023-8-28_11-1-34.png