Basic Math for Game Development with Unity 3D by Kelvin Sung & Gregory Smith

Basic Math for Game Development with Unity 3D by Kelvin Sung & Gregory Smith

Author:Kelvin Sung & Gregory Smith
Language: eng
Format: epub
ISBN: 9781484254431
Publisher: Apress


ShowSubV12 = new MyVector() { // Show V1 - V2

VectorColor = Color.gray };

PosSub = new MyVector() { // Show as position vector

VectorAt = Vector3.zero,

VectorColor = Color.gray };

ShowNegV2 = new MyVector() { // Show -V2

VectorColor = new Color(0.9f, 0.9f, 0.2f, 1.0f) };

PosNegV2 = new MyVector() {

VectorAt = Vector3.zero,

VectorColor = new Color(0.9f, 0.9f, 0.2f, 1.0f) };

}

As in all previous examples, the Debug.Assert() calls ensure proper setup regarding referencing the appropriate game objects via the Inspector Window. The rest of the Start() function instantiates the many MyVector variables for visualization, setting their colors and display positions. The Update() function is listed as follows:void Update() {

Vector3 V1 = P1.transform.localPosition - P0.transform.localPosition;

Vector3 V2 = P2.transform.localPosition - P1.transform.localPosition;

Vector3 sumV12 = V1 + V2;

Vector3 sumV21 = V2 + V1;

Vector3 negV2 = -V2;

Vector3 subV12 = V1 + negV2;



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.