Point a 3D arrow the same direction as a vector

I have a 3D arrow model. How do I point it the same direction as the vector that would be drawn from 0,0,0 to the vector point. The 3D Arrow model is originally pointing towards +X.

Here’s what I’ve tried so far but it does not seem to work:

var vec=Vector3(5,5,0);
var rotation = Quaternion.LookRotation(vec);
arrow.transform.rotation = rotation;

The easiest way to do this, since Unity’s ‘Forward’ direction is +Z, would be to create a new empty GameObject called ‘ArrowHolder’ or something, set the 3d arrow to be a child of it, then rotate the arrow 90º so that it faces towards the ArrowHolder’s ‘forward’ direction locally. That way, all you have to do is set the ArrowHolder to look a direction and it’ll automatically handle it.

The LookRotation function assumes that the thing you want to aim starts pointing down the Z axis, not the X. You can fix this by doing one of the following:

  1. Modeling your arrow so that it points down the Z axis instead

  2. Parenting your arrow model under an empty GameObject, rotating the arrow model so that it points down the Z axis, and point your aiming/rotation script at the empty GameObject instead.

  3. use Quaternion.FromToRotation() instead, which rotates from an arbitrary vector to another vector. e.g.

    arrow.transform.rotation=Quaternion.FromToRotation(new Vector3(1,0,0),vec);

3 might look the easiest but you could get some unwanted spin/rotation (along the long axis of your arrow) because there is no way to specify an up vector. #2 is probably the most painless unless it is easy for you to remodel your arrow.

You should make the arrow a child of another transform, let’s call it the ‘pivot’. The pivot will be what you have the rotation script on.

Now make sure the arrow child points +Z instead of +X by rotating the child -90° around the Y axis.