Scoping same two collided objects of same type

AnswerStackCategory: Loops (Fastloops/ForEach)Scoping same two collided objects of same type
Dylan Dexter asked 5 years ago

If I have two objects of the same type or qualifier tested for collision, then how do you access both collided objects individually.
This seems simples with two different object types, but causes some difficulty scoping two of the same type?

Dylan Dexter replied 5 years ago

To be more clear, – when two objects of the same type collide with each other, – how do you access them independently?

1 Answers
Dylan Dexter answered 5 years ago

Ok, have managed to work out that I can use a collision flag in the objects to help scope both collided objects, ie.-
1) Test for Object collides with same object type, –
Collision detected, then Set Object collision Flag to True – This seems to set the flag to True for both collided objects.
2) Fast loop through all the objects,-
Scope the object using ‘On loop’ & object ID = loop Index, & Object Collision Flag = True.
Then once this condition is met, store the object reference in a variable or list object for later reference.
3) Access either of the two collided objects by scoping the object type and comparing the loop index with object ID,
and comparing the objects reference value value with stored object reference.
Once scoped you should have access relevant object.
At the end, set the Collision Flag to False and repeat process.