|
ok so i have a selector that tells me the name of my object in my multi-dimensional array, but i want to know how i can have it send me back the index of that object. can anybody help me out?
(comments are locked)
|
|
Given that you know the transform (I assume it is an array of transforms?) you can use And then you can use xPos and yPos! If they return -1, it means the selected transform isn't in the grid (oops); why do you have that break there?
Oct 10 '11 at 04:49 AM
IMTRIGGERHAPPY9
break tells it "Ok I'm done with this now, don't bother looping through the rest of the iterations. kthxbai!". I've got it there to save time, although you don't techincally need it.
Oct 10 '11 at 04:53 AM
syclamoth
if i where to turn this into a function i would have it return the xPos and the yPos right? and then i would send it my array that i have? thats it?
Oct 10 '11 at 04:56 AM
IMTRIGGERHAPPY9
thanks dude if i could give you a million credit points i would right now! you have been so helpful!
Oct 10 '11 at 05:00 AM
IMTRIGGERHAPPY9
Kind of? You can't return two values at a time without defining a type which contains them, and you'd need to send it both the array, and the transform you're searching for. I'm really not sure what the context of what you're doing is... (well obviously it's your TD that you are making, but more specifically)
Oct 10 '11 at 05:01 AM
syclamoth
(comments are locked)
|

Depends on how your selector works! Presumably, to get the name of the object, you had to have the index at some point anyway- so return that instead!
I think you can use IndexOf(object), but that might only work for generic lists (I can't remember...)
my selector is using raycasting