Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted Making player face wall

Discussion in 'Scripting' started by gjfnasjdnasklnd, Jun 29, 2020.

  1. gjfnasjdnasklnd


    Jun 15, 2020
    I have a character controller, if it touches a wall its status will become climbing. I need to transform the character so they face the wall perpendicular/head on.

    Top down view (this is a 3D project). So character walks into wall/ladder.
    When OnTriggerEnter happens on character controller compound colliders, make character controller face wall.

    I have a point direction Vector3 variable so I know which direction the character is facing but I don't know how to get the wall surface position(?) and how to use it on the character.
  2. Kurt-Dekker


    Mar 16, 2013
    Various Raycast functions can optionally give you a RaycastHit object back. One of the components of that is the
    field, which is the vector pointing away from the surface at the precise point you hit it. With that you can orient your player to face the opposite direction, i.e, into the wall.
    Joe-Censored likes this.