I have a Playercontroller gameobject which is looking at the center of the game world with LookAt function.
That Playercontroller has a child object which has the graphics on it and I would like to rotate that child gameobject in its local axis(for example when A is pressed it rotates it to the left and when D is pressed then to the right)
This is what i use for now in the child gameobject for WASD input:
if (Input.GetKey ("a")) {
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.AngleAxis(-90, Vector3.up), Time.deltaTime * rotationSpeed);
}
It works at the beginning because the playercontroller has 0, 0, 0 rotations, but obviously the child object doesnt rotate correctly when i start to move. I have tried transform.localRotation but it gets really weird results(continuously rotation, does not stop at wanted Y axis degrees).
Any help or guidance would be greatly appreciated