I'm sure there is an easy way to do this but I haven't seen it and not been able to find it in my searching unfortunately. I'm looking to reference two of the same object.
So for example lets say I have created 10 instances of an object, I want to loop through those 10 objects and changes a variable on each of them but reference another instance of the object. So lets say we do something like this (writing in Sudo code)
On Ball Collision (We'll call this #1)
For Each Ball (We'll call this #2)
Ball#2.height = Ball#2.height - Ball#1.height
You can see I'm trying to reference 2 objects which are both called ball, but not sure how I would be able to do this. Another example of this would be I had several buckets and I wanted to move the contents of the buckets down the line
For Each Bucket (#1)
For Each Bucket (#2)
If Bucket#2.id = Bucket#1.id + 1
Bucket#1.contents = Bucket#2.contents
A way around this would be to store an the instance of the object in a variable. When I try and search for this all I'm able to find is information on instance variables, and while they are helpful they aren't exactly what I'm looking for ;)
I hope this makes sense, and hopefully someone will be able to help me out with this. Any help I'd be able to get would be greatly appreciated!