Quaternions

Discussion in 'Rust Development' started by DylanSMR, Aug 5, 2016.

  1. So I have a basic understand of how these work.
    You provide a new Quaternion four values: (x,y,z,w).
    My question what do these do? I was messing trying to get a turret to flip and im loosing my mind. Ive tried searching through unity forum posts but its not working so far. here is my code:
    Code:
                        //turret.KillMessage();
                        AutoTurret autoTurret = GameManager.server.CreateEntity(pf, new Vector3(turret.transform.position.x, turret.transform.position.y + 3f, turret.transform.position.z), new Quaternion(13f, -0.9f, 1.4f, 0.1f), true) as AutoTurret;
                        autoTurret.Spawn(true);
                        autoTurret.health = 1000;
                        timer.Repeat(0.0001f, 15, () => autoTurret.health = 1000);
                        timer.Once(5, () => autoTurret.KillMessage());
     
  2. Quaternions are a mathematical concept that can be used to describe rotations.
    To understand them you should first try to understand complex numbers, which can be used to describe rotations in a 2D space.
    EDIT: Here's a casual introduction:
     
    Last edited by a moderator: Aug 5, 2016
  3. After watching the video (you should at least have a very basic understanding of quaternions), take a look at the Unity API, which provides a bunch of helper functions so you can work with Quaternions more easily.
    The two you might find the most intuitive:
    Unity - Scripting API: Quaternion.AngleAxis Rotate an object around an axis that is described by a vector (the video explains this method!)
    Unity - Scripting API: Quaternion.Euler Rotate an object by x, y and z degrees (also explained in the video).