Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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.