Dear all,
I am currently going through the unity 2D course (Laser Defender) and struggle to implement something I want to add. Basically, the player ship should be tilted a bit when it is moved left or right:
I thought this would be a easy thing…but somehow I really struggle. I already searched through code sniplets but was not able to implement what I need. The player ship does weird things I do not understand
This is what I have currently to get the ship tilted but it does not work as intended:
float z = Input.GetAxis("Horizontal") * tilting;
Vector3 euler = transform.localEulerAngles;
euler.z = Mathf.Lerp(euler.z, z, 2.0f * Time.deltaTime);
transform.localEulerAngles = euler;
tilting is an Integer with the tilting angle assigned to it.
Thanks for your help!
With best regards,
Weltenlicht