I use Vector4s data structures to store all my positional data for my gameObjects, using the W component as a metadata placeholder. Can I easily assign transform.position using the XYZ of a Vec4 while discarding the W?
Here is how I’d like the code to read:
var g_MC : new Vector4[n];
var g_MCgo : new GameObject[n];
g_MCgo<mark>.transform.position = g_MC<mark>.Vector3 + Vector3.up;</mark></mark>
Here is the only way I can currently get the code to work:
g_MCgo.transform.position = Vector3(g_MC.x, g_MC.y, g_MC.z) + Vector3.up;
Any and all elegant help is appreciated.
You could use an extension method like this:
public static Vector3 ToVector3(this Vector4 parent)
{
return new Vector3(parent.x, parent.y, parent.z);
}
Then just do:
g_MCgo<mark>.transform.position = g_MC<mark>.ToVector3() + Vector3.up;</mark></mark>