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 How to get a position based on rotation of object

Discussion in 'Scripting' started by CrustyPablo, Jun 30, 2023.

  1. CrustyPablo

    CrustyPablo

    Joined:
    Sep 29, 2020
    Posts:
    7
    I want to get 6 positions around a cube that I have but it has to be based on the direction it is facing. For example, I want to get a position 1 unit in the direction of the left face of the cube, no matter what the rotation is. I cant use
    transform.forward
    for everything right? I'm just wondering if there's a function or some math that I can do that I just can't figure out on my own.
     
  2. Elhimp

    Elhimp

    Joined:
    Jan 6, 2013
    Posts:
    71
  3. zulo3d

    zulo3d

    Joined:
    Feb 18, 2023
    Posts:
    510
    front=transform.forward
    back=-transform.forward
    right=transform.right
    left=-transform.right
    top=transform.up
    bottom=-transform.up
     
  4. CrustyPablo

    CrustyPablo

    Joined:
    Sep 29, 2020
    Posts:
    7
    Awesome thank you so much