Hi,
I have some problem with my game 2D. I need to my turret rotate faced to target, only in Z-axis. When i use LookAt or Quaternion.LookRotation i it always rotate wrong (becouse it’s calculate for 3D space i guess). Anyone have good solution for that?
Sorry for my english.
You’ll probably want to figure out the angle first and then rotate around the desired axis for that amount of degrees (i used y)
float angle = Vector3.Angle(myTransform.position, targetTransform.position); myTransform.Rotate(Vector3.up, angle);
Thank you dterbeest for answer!.
I try Your example. Actually rotates the axis of x but that angle was calculate wrong. I attached image from prototype.