Search Unity

Help aligning a Vector3

Discussion in 'Scripting' started by ChristopherYabsley, May 3, 2020.

  1. ChristopherYabsley

    ChristopherYabsley

    Joined:
    Jan 16, 2014
    Posts:
    16
    Hi,

    I have this quick and dirty code that aligns a players distance to a ladder on the z axis. How would I make it so it performs this same function regardless of which way the ladder faces?

    Sorry in advance is this is super obvious, I suck at vectors.

    upload_2020-5-3_12-49-57.png '
     
  2. ChristopherYabsley

    ChristopherYabsley

    Joined:
    Jan 16, 2014
    Posts:
    16
    Solved by converting the players position to a local one, performing the z operation there, and then converting it back to world position.

    upload_2020-5-3_13-25-28.png
     
    PraetorBlue likes this.
unityunity