- Home /
find overlap rotation between two vectors[Solved]
public Vector3 v1, v2,v3;
private void Update()
{
v3 = 0.5f * (v1 + v2);
Quaternion Q = Quaternion.LookRotation(v2-v1);
Collider[] test = Physics.OverlapBox(v3, new Vector3(1, 1, 10), Q);
}
v3 is the position between v1 and v2 the only thing that I need is the rotation , how can I find it?
Answer by Bunny83 · Jan 17 at 05:01 PM
The easiest way is to use Quaternion.LookRotation(v2 - v1);
This would alight the z axis with your vector between v1 and v2
I already did that but it wasn't working
as you see it doesn't look at objects ,it should be like when you use lookat , but I dont want to use transforms :)
Before you do anything else you should switch your gizmo mode to local and pivot. Currently it's clearly set to global.
Apart from that we can't even tell what we are looking at. The code in question just calculates a rotation for the OverlapBox call. So all this does not give any visual representation.
ps: you have edited your question and included this comment:
//Quaternion Q = Quaternion.LookRotation(v1,v2); its not working
This line, when uncommented, makes no sense at all. I have subtracted the two vectors from each other. You passed the first as direction and the second as up vector. This makes no sense at all. Are you sure you used the code I posted? It's a $$anonymous$$us sign between v2 and v1, not a comma.
Your answer
