I am trying to instantiate cube prefab between 2 objects.I am drawing lines with vectorsity and when i completed shape my script trying to instantiate object between 2 points.
My lines using vector3 and also i am working on X / Y axis. when i instantiate prefab between 2 points i have to rotate them in Z axis. But when i tried to instantiate an object there is no rotations applied.
That black line is my cube on isometric cam view and i want to rotate them between 2 vector3 points. I need some advices for calculating rotation on z axis.
For the object you are putting in the middle, you have to pick a side you are going to have face along the line. So given you are saying the rotation along the ‘z’, I’m going to assume you want the right side of the object to face the second square. Given the Vector3 positions of the two squares as ‘pos1’ and ‘pos2’, you can align the right side as:
Another solution is to fist construct your object you are placing so that the side facing positive ‘z’ is the one you want to point at block 2 (pos2). Then you can do this: