in inspector gameobject i'm using starting rotation "-90", when run print(transform.eulerangles.x)
270 (ditto transform.localeulerangles.x
).
if tilt gameobject
downward, inspector x value gets bigger (say, -85) should. printed transform.eulerangles.x
gets bigger, 274.
here's things weird:
if tilt gameobject
upward inspector x coordinate gets smaller (ex, -95), should, printed eulerangle.x
value gets bigger (here 274). if rotate object or down eulerangle.x
being 270, x value increases regardless.
i'm doing wrong here, after lot of troubleshooting still can't figure out what. thoughts?
eulerangles convoluted process in unity3d. should never increment/decrement or set values in inspector or via code. should use absolute values read , set it.
don't increment or decrement values, fail when angle exceeds 360 degrees. transform.rotate use instead.
here sample code in unity3d documentation example:
using unityengine; using system.collections; public class exampleclass : monobehaviour { public float yrotation = 5.0f; void update() { yrotation += input.getaxis("horizontal"); transform.eulerangles = new vector3(10, yrotation, 0); } void example() { print(transform.eulerangles.x); print(transform.eulerangles.y); print(transform.eulerangles.z); } }
this taken directly documentation: https://docs.unity3d.com/scriptreference/transform-eulerangles.html
also transform.rotate documentation: https://docs.unity3d.com/scriptreference/transform.rotate.html
the inspector give funky value vs when log it. consistency print(transform.rotation). should retain similar values across inspector , code.
Comments
Post a Comment