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());
Quaternions
Discussion in 'Rust Development' started by DylanSMR, Aug 5, 2016.
-
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 -
Hmm thanks. I've managed to flip a turret: Lightshot — screenshot tool for Mac & Win was on the floor not the roof)
-
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). -
a quick note, here is a website I used to help me get a idea how to rotate something with Quaternions.
Maths - Euler to Quaternion Examples 90 degree steps - Martin Baker
