Quantcast
Channel: Latest Questions by blipton
Viewing all articles
Browse latest Browse all 9

Problem titling an object from its center (Pitch/Roll) (screenshot)

0
0
I've imported an .fbx asset, and have the main camera pointing to it, but the way I've implemented the c# code, changes in the pitch/roll angles moves the object off screen rather than pivoting on it's center! https://giphy.com/gifs/3oKIPjvGn69kIq4otq The desired object angles are drawn using this function: void SetPosByAngle ( float fPitch, float fRoll ) { Vector3 LowerLimit = new Vector3(0, 0, 0); Vector3 UpperLimit = new Vector3(180, 180, 180); // Normalize from -180/+180 to -1/+1 fPitch = (fPitch) / 180.0f; fRoll = (fRoll) / 180.0f; Vector3 AngleDiff = UpperLimit - LowerLimit; Vector3 CalculatedAngle = new Vector3(-fPitch * AngleDiff.y, 0, -fRoll * AngleDiff.x); TragetAngle = LowerLimit + CalculatedAngle; transform.localEulerAngles = TragetAngle; } Probably TMI, but the angles sent to the function above are calculated via: fPitch = (float) (Math.Atan2(YAxisAccelerationData,ZAxisAccelerationData)+M_PI)*RAD_TO_DEG; fRoll = (float) (Math.Atan2(ZAxisAccelerationData, XAxisAccelerationData)+M_PI)*RAD_TO_DEG; Given 2 angles, how can I simply pivot the object so that it tilts without moving?

Viewing all articles
Browse latest Browse all 9

Latest Images

Trending Articles





Latest Images