I have two points (cube game object) in Unity, P1(x,y,z) and P2(x,y,z) and I have to set the MainCamera position and rotation along the vector between P2P1.
I tried different methods but was not successful. All suggestions are welcomed. Thanks.
I have two points (cube game object) in Unity, P1(x,y,z) and P2(x,y,z) and I have to set the MainCamera position and rotation along the vector between P2P1.
I tried different methods but was not successful. All suggestions are welcomed. Thanks.
We can find angle between 2 vectors according the dot production.
angle = arccos ( a * b / |a| * |b| );
where:
a * b = ax * bx + ay * by + az * bz
|a| = sqrt( ax * ax + ay * ay + az * az )
|b| = sqrt( bx * bx + by * by + bz * bz )
Or just use this method: http://docs.unity3d.com/ScriptReference/Vector3.Angle.html