Search Unity

How do you transform local position according to a normal?

Discussion in 'Scripting' started by Draconic, Jul 30, 2014.

  1. Draconic

    Draconic

    Joined:
    Oct 12, 2013
    Posts:
    82
    The way I have slopes in my game is by calculating the normal of the surface you are standing on. However, in this game you can walk on walls, which rotates the player. So, instead of moving +5 to x, it would be changing position by transform.right * 5. Right now, a ray is cast in the direction -transform.up, which returns a normal, then I want the player to move accordingly, no matter what direction it is facing. Is there a way to convert the normal to the player rotation, so that if the player is rotated 45 degrees and also the wall is rotated 45 degrees, the movements stay the same?
     
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    It sounds like you're trying to make a surface tracker? You want the player to stick to the ground/walls in the same manner an ant walks on grounds/walls? Correct?