transform.eulerAngles + transform.Rotate not working sync
Quick question, I have a simple kite going up and rotating as it goes up (to always face the handler). More, I use left and right arrows to change angle, so it can move left and right. Here is my Update() // Kite height float currentHeight = transform.position.y; // Kite angle fct of kite height float kiteAngle = Mathf.Asin(currentHeight / lineLength) * Mathf.Rad2Deg;
// Move Left and Right
transform.Rotate(0, 0, 250 * Input.GetAxis("Horizontal") * Time.deltaTime);
if ( kiteAngle < 89 && transform.position.y < lineLength && transform.position.z > 0)
{
// Simulate Wind
transform.Translate(0, windSpeed, 0);
// Adjust kiteAngle
transform.eulerAngles = Vector3.left * kiteAngle;
}
But while my kite is entering the if clause, the "Move Left and Right" is not working. Any idea ? It seems that I can't transform eurlerAngles at the same time as Rotate, what is the clearest way to combine boths rotations ? Sorry if that's obvious, it's my first script :)
Answer by jjf21 · Sep 10, 2021 at 02:52 PM
Found a Solution by modifying my EulerAngles transform like this
transform.eulerAngles = new Vector3(-lineAngleX, lineAngleY, transform.eulerAngles.z + 3 * Input.GetAxis("Horizontal"));
I needed to take the current angle and add degree depending on the key press.