how to to rotate a object in 2D to known position values
This is for my 2D game. In my Unity Editor i rotated my object (bat) manually to know the rotation values. See below. I noted down those values. Now i want to rotate to these positions when a key is pressed.
When a Key is pressed i want to rotate the object to the highlighted position. I tried below but not working Approach 1- Below - Result: Its rotating when trying different direction.It seems its rotating from with respect to its position.
if (Input.GetKey(KeyCode.A))
gameObject.transform.Rotate (getVector3FromKnownXYZ ());
Approach2:
Vector3 rot_pos = getVector3FromKnownXYZ ();
> gameObject.transform.rotation.Set (rot_pos.x,rot_pos.y,rot_pos.z,1);
Approach 3:
gameObject.transform.LookAt(getVector3FromKnownXYZ())
Approach 4:
gameObject.transform.Rotate (( getVector3FromKnownXYZ () -gameObject.transform.position ).normalized)
Result: No change Note: getVector3FromKnownXYZ() - This method will construct a new Vector 3 object with known values from image.