Hi all!
I’m unsure if my Logic is unsound or I am just not figuring out how to do this right. I’ve been searching through the Unity Forum, StackOverFlow and MSDN all week, and I think I am just plain missing something. I don’t have solid code examples for this , because I’ve been cobbling from examples, but don’t know if I am anywhere near the mark.
Script A has a list of Gameobjects populated by a Collider (ever changing).
Script B lives on all the potentially hit Game Objects, that provides variables I need for other things.
On Script B, I want to find out what Index position that particular object holds on the list on Script A, Then I want to find out what is in the slot right above it (so Index - 1) and have that object do something to the other one. I am sadly, really stuck on getting the Index position.
So example:
Script A
MyList
Dog
Cat
Banana
Script B
find out what position Cat is at
what Item is above it
Call another Script to do things.
However, the objects in the list continually change.
So how do I get the index of an the object script B is on, from another script?