Sorry in advance if this is difficult to follow, I'll draw up diagrams if need be.
I'm using Unity3D to develop a game and am having trouble with the player's transform. The game is first person, 3D, and there are points where the gravity will change, allowing the player to walk along a wall - This is all up and running.
When the players gravity is such that it walks on a wall, when I rotate the character's to look around its transform behaves strangely. It can rotate through a full circle and there are no visible problems with the character when playing the game.
If I look at the inspector in Play Mode, let's say I'm continually turning right, the following happens:
The sequence would go something like: 0, 1, 2 ... 88, 89, 90, 89, 88 ...1, 0, 359, ...271, 270, 271 ... 359, 0, 1 ...89, 90, 89 ...
etc.
When I watch the transform in the Scene view, it goes back and forth like a wiper on a car window, when but my character itself is just continually turning in one direction. When I am on the ground it makes full circles as it should, even though the value is still "ping-ponging".
What causes this to happen? It doesn't happen when the player character is on the floor, only when it is on walls. The reason I need to know is because there is something else in the game that relies on mimicking the player's rotation, and this problem is giving me behaviour that I don't want.
Any help would be greatly appreciated, I'd had trouble with this for a while!
You shouldn't rely on angle values in Unity, it uses quaternions for rotation:
https://unity3d.com/ru/learn/tutorials/modules/intermediate/scripting/quaternions http://docs.unity3d.com/ScriptReference/Quaternion.html
Strange behaviour came up from the fact, that multiple combinations of angle values are representing the same rotation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.