multiple values in an argument

In the following function:

Instantiate(object,transform.position, transform.rotation);

What I seem to have trouble wrapping my mind around is how exactly do you have more than 1 value in a single argument?

In Instantiate, it’s (object,position,rotation) right?

How does a full XYZ fit into a single argument?

I’m new with this programming, and it seems very unfamiliar to me.

transform.position returns an object of type Vector3. So instead of writing transform.position, just give it a vector3 instead, like this:

Vector3 (1, 2, 3);

What I don’t understand is how 3 values are being placed into 1 argument.

Function(Argument0,Argument1,Argument3)

I’m used to assuming that a single argument can only hold 1 variable, not 3 in the case of a vector.

Is it really using one large number that is processed bit-wise in the function itself to provide the information for 3 variables? Kinda like a hex color code does with RGB? #RRGGBBAA? 255,255,255,255

No, a Vector3 is a struct that holds 3 separate single-precision floating point values. Actually an RGB value like that is 4 bytes; that’s sort of a struct too.

–Eric

Function arguments and return values are all of type Object. Everything inherits from this base class - Int, Double, Char, String, Array, Struct, Class… everything.

If you were developing a 128bit HDR app, you’d want the RGBA components to be of type Double, with a normal range 0.0 to 1.0

If you dig deep enough, you’ll probably find how String is really an array of Chars.
“string” would be [‘s’,‘t’,‘r’,‘i’,‘n’,‘g’,‘\0’]
But what is each Char? Old skool 8bit or Unicode 16bit?

You can do bitwise operations on a Struct if the members are aligned/padded correctly, but the days of Int’s domination are over.

The point is you don’t worry about how the underlying structure of the variables work.

I don’t think anyone uses or ever used the Hex colours for anything other than cut/paste for webpages. :smile: