#Rotation Problems

1 messages · Page 1 of 1 (latest)

strange plume
#

`public class RollSwitch : MonoBehaviour
{
[SerializeField] private GameObject eleron_Left;
[SerializeField] private GameObject eleron_Right;
[SerializeField] private float roll;
[SerializeField] private float speed;
private Vector3 direction;

// Update is called once per frame
void Update()
{
    roll = Input.GetAxis("Horizontal");

    eleron_Left.transform.rotation = Quaternion.Euler(-90 + roll * 25, transform.rotation.y, transform.rotation.z);
    eleron_Right.transform.rotation = Quaternion.Euler(-90 + -roll * 25, transform.rotation.y, transform.rotation.z);
}

}`

restive flower
#

Okay a few issues here in the code

strange plume
restive flower
#

transform.rotation.x for example, it's not an angle in degrees, so you can't treat it as such by putting it in Quaternion.Euler()

strange plume
#

i mean ive tried the same with Quaternion.Identity but i get the same results

restive flower
#

Rotations are expressed in Quaternion, which is a complex object that represents a rotation on 4 axes

#

Each component of the Quaternion ranging from -1 to 1

strange plume
#

`public class RollSwitch : MonoBehaviour
{
[SerializeField] private GameObject eleron_Left;
[SerializeField] private GameObject eleron_Right;
[SerializeField] private float roll;
[SerializeField] private float speed;
private Vector3 direction;

// Update is called once per frame
void Update()
{
    roll = Input.GetAxis("Horizontal");

    eleron_Left.transform.rotation = Quaternion.Euler(-90 + roll * 25, Quaternion.identity.y, Quaternion.identity.z);
    eleron_Right.transform.rotation = Quaternion.Euler(-90 + -roll * 25, Quaternion.identity.y, Quaternion.identity.z);
}

}`

#

this gets me the same problems

restive flower
#

Same problem in the code

#

Quaternions don't store rotations in degrees

hardy coral
#

Quaternion.Euler(-90 + roll * 25, Quaternion.identity.y, Quaternion.identity.z);

why...

restive flower
#

I'd just use the local rotation instead of the world rotation to move the ailerons, it's simpler that way

hardy coral
#

like SPR2 said, they are not degrees so they dont go past 1 or-1