I’ve got my character, and a trigger. The trigger triggers an animation and sets the position before and after the animation. However, the triggered animation is rotation sensitive and I could really do with getting the trigger to alter the rotation of the character too.
For the position I just used:
transform.position = Vector3(-113, 43, 462);
So I figured something similar would apply:
transform.rotation = Vector3(-0, 150, -0);
But it doesn’t like it! I checked the docs and it’s going on about eulers and quaternions and I just don’t understand it this late on a saturday night
Quaternions are not an easy concept to understand. Basically you need to abstract yourself from them. You need to know that a Quaternion is another way to represent a rotation, but unlike euler angles which are in 3 dimensional space, Quaterions are represented on 4 dimensional space (so it’s not possible to imagine a rotation on Quaternion - at least not for me!).
If you had some math, you probably learned Complex Numbers, where square root of -1 is ‘i’. On Quaternions you have the same, but with ‘i’, ‘j’, and ‘k’ (i.e. like an extension of Complex Space).
Quaternions are important because they eliminate a rotation problem that euler angles have (if you rotate 90º around an axis, you loose a degree of freedom, so when you apply another rotation you will get some “odd” rotations).
Given how few people understand quaternions (I’ve always been good at math, and I’m still having a hard time wrapping my head around them), could there be some constants and/or more easily understood constructors for them?
For example, a constructor that is passed a single Vector3 could make it face that vector and assume that up = up. This would make easy statements like facing = Quaternion(Vector3.left);
In the meantime, could someone be so kind as to post the xyzw constructor values for some of the easy quaternions (like forward, backward, left, right)?
The problem with constructors vs. static functions is that you can not tell from the constructor name what it will do with the inputs. Should a constructor that takes two Vector3s as parameters treat them as a direction and a world-up vector like Quaternion.LookRotation does or should it treat it as a from and to vector pair like Quaternion.FromToRotation does? The same applies to a constructor that takes a single Vector3. Should it treat is as Quaternion.Euler does or should it do the same as the single-parameter version of Quaternion.LookRotation?