Hi Guys,

I feel like this should be a pretty simple thing to do, but I seem to be mixing up some things –

I’ve got point A on a curve. I’d like to offset this point by a fixed distance, perpendicular to the curve direction at that point, resulting in point X.

So far, what i’ve done is query the point directly in front of point A, point B. I then subtract point B from point A, to obtain the vector AB (or C in the diagram).

This is where I’m starting to get confused:

- In theory, using AB.right should give me a vector perpendicular to AB, correct?
- I now divide this vector by it’s magnitude to normalize it.
- I now multiply this vector by the scalar offset I’d like point X to have. This should give me vector D.
- Now (really confused) the cross product of point A and vector D should give me point X?

I’d really appreciate it if anyone could point out where my mistake is, or what I should be doing differently.

Thanks,

-Juanelo

The point where you are going wrong is using AB.right. Vector.right is just shorthand for `new Vector3(1,0,0)`

, not a vector orthogonal to the current instance.

You need another vector to make a plane so you can find a unique orthogonal vector (see Jessy’s comment). I suggest you take Vector3.up and then use Vector3.Cross.

Ah, fantastic, thanks for the feedback! All along I had thought Vector3.right was local, relative to the vector’s direction!

Got everything working now:

Thanks, fellas.

(for those interested, this also helped a bunch: http://unity3d.com/support/documentation/Manual/ComputingNormalPerpendicularVector.html)

Think you could also compute a “look” from A to B, and compute local right from there:

```
Quaternion ABlook = Quaternion.LookRotation(B-A);
Vector3 X = A + ABlook * Vector3.right * d;
```

It seems like not enough, but the LookRotation gives you the arrow from A to B *and* the line going up. That gives enough info to compute a single Right.