Search Unity

Rotating vector relative to direction

Discussion in 'Scripting' started by Sendatsu_Yoshimitsu, Jun 19, 2019.

  1. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    This is probably absurdly simple, but I'm trying to find specific coordinates in a 90 degree (2d) in front of a relative vector. I know I can get relative forward with (destination - origin).normalized * distance, but given that I don't have a transform to explicitly rotate, how do I calculate a Vector3 which rotates that point n degrees around the destination vector?
     
  2. flaminghairball

    flaminghairball

    Joined:
    Jun 12, 2008
    Posts:
    868
    Code (CSharp):
    1. Quaternion.Euler(0, 0, 90) * (destination - origin)
     
  3. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    Ooh derp, for some reason I had discounted quaternions entirely and was messing around with the dot product. Thank you so much!!