First, transform.position doesn’t ‘convert’ into a Vector3, it is a Vector3.
I’m not 100% sure what you are asking but I’ll give it a stab. What I find often is:
-
Vector3→Vector2→Vector3
You can cast it both ways. CastingVector3toVector2will lose the z -
Quaternion→Vector3→Quaternion
You can useQuaternion.eulerAnglesto get aVector3as it appears in the inspector’s rotation bits. The vector will hold the degrees for each axis.
You can also get aQuaternionfromVector3withQuaternion.Euler(Vector3). Note that converting it toQuaternionapplies the axis rotations in a specific order (first z, then x, then y) and that is important because it can affect the final rotation. Although I’ve never had to worry about this, it’s important to know this in case you do run into issues -
float→int
I mention this one because there are 3 different methods in Unity and each one has it’s own use to consider. Actually, there are others but these are specific and can be the answer to you hitting an enemy with 1 health for 1 damage and it not dying.
We haveMathf.RoundToInt(float)which will just round the decimal like we kinda learned in school. If the fraction is less than 0.5 it will round down, if it’s more than 0.5 it will round up and if it is exactly 0.5 it will round to the even integer. That is; 1.5 will become 2 and 2.5 will also become 2.
Then there’sMathf.FloorToInt(float)which will always round down (1.1 will become 1 and 1.9 will also become 1), and
Mathf.CeilToInt(float)which will always round up (1.9 will become 2 and 1.1 will also become 2).
These are easy to remember because the ‘floor’ is down and the ‘ceiling’ (‘Ceil’ is short for ceiling) is up.
That’s about it, though. I can’t think of any other conversions right now.