how to use object[] in instantiateSceneObject

Sorry I guess I feel like this is a noob question, and I should know it, but I'm finding it confusing.

I have an array of Vector3 values and I want to pass them into the instantiate so I can properly setup each copy of the avatar. I noticed the InstantiateSceneObject has an optional parameter object[] and I was hoping I could use it to pass the list of Vector3 values, but I can't figure out how to make the assignment work, or if its not possible?

I tried typecasting from Vector3[] to object[] but it doesn't like that. I tried just using the Vector3[] variable and it didn't like that either.

is there an example of how I can use the object[] variable? I've always used traditional data types or GameObject. I'm not sure how to leverage object in this context?

Thanks

Larry

Comments

  • 2 ways off the top of my head...

    A) treat the vector array as an object in the object array

    Vector3[] vecArray;
    ... //set up your array of vectors

    object[] objArray = new object[] { vecArray };

    Or you could do...

    B) cut out the middleman and treat each vector as objects in the object array

    Vector3 vec1;
    Vector3 vec2;
    Vector3 vec3;
    etc...

    object[] objArray = new object[]{ vec1, vec2, vec3,...};
  • Ok I see what ur saying. I'll give it a try.
  • yep worked like a charm, so obvious now that I look at it.

    I was trying to do things like:

    Vector3[] myvec;
    object[] myobj;

    myobj= (object[])myvec;

    which don't work. However doing

    myobj[0] = myvec;

    works perfect, thanks for clarifying.
  • you're welcome :}
  • I think you should also be able to call the method with several vectors: method(..., vector3a, vector3b) and it should "convert" to object[] when sent.