how to get transform rotation unity code example
Example 1: transform.rotation - 90 unity
var lookPos = target.position - transform.position; lookPos.y = 0; var rotation = Quaternion.LookRotation(lookPos); rotation *= Quaternion.Euler(0, 90, 0); // this adds a 90 degrees Y rotation var adjustRotation = transform.rotation.y + rotationAdjust; //<- this is wrong! transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
Example 2: transform.rotation.x unity
transform.eulerAngles = new Vector3( xRotation, transform.eulerAngles.y, transform.eulerAngles.z );