I have a direction to my target object, which is in a Vector3 format. I want cast a number of rays, as offsets from this initial direction.

X is the object. D is the direction the player needs to travel in. A & C are other directions that I want to cast rays towards to check for impacts.

A    D    C
 \   |   /
  \  |  /
   \ | /

I was trying to add an offset, such as Vector3.Right to the Direction and then normalise the result, however this only works if everything is oriented towards World Space.

So how can I convert and add a direction (Vector3.right) as an offset to an existing direction?

I'm fairly sure I just have World Space and Local Space directions mixed up but can't see an easy way to convert between this with Vector3?

  • 1
    \$\begingroup\$ myVector + Quaternion.LookRotation(myVector) * myOffset \$\endgroup\$
    – DMGregory
    Feb 14 '17 at 6:08
  • \$\begingroup\$ Do you have an Up vector? - I mean, the vectors XA, XD and XC need to be coplanar, but on what plane? \$\endgroup\$
    – Theraot
    Feb 14 '17 at 8:28
  • 1
    \$\begingroup\$ Correct me if I'm wrong, but it looks like you're just want to rotate the vector D. This can easily be reached by multiplying the vector by complex number: betterexplained.com/articles/…. For Unity: answers.unity3d.com/questions/46770/… \$\endgroup\$ Feb 14 '17 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.