List (or array) of on screen objects

Greetings and salutations,

I am building an auto-targeting system and was wondering if there is a way to create an array of the objects currently being shown by the camera that I could then cycle through to find “shootable” targets. So far googling has not revealed much which makes me believe I am once again in a situation where I do not really know the technical term for what I am searching for.

Any help that any of you could lend would be most appreciated.

You can use OnBecameVisible and OnBecameInvisible to add/remove objects from the array. Keep in mind the editor camera also counts, which makes testing in the editor a little tricky sometimes.

–Eric

Thank you very much. Hopefully that coupled with ray-casting will provide the solution I’ve been looking for.

Hey I made a simple JavaScript that might help but you’re going to have to go from there. The script is called follow and it makes an object follow another object. Like it keeps the same place but it follows the other object with it’s rotation.

240390–8603–$follow_211.js (74 Bytes)

You could do the following:

  1. Place all shootable targets on a Layer e.g. Enemies
  2. Get a collisionbox on the camera.
  3. Check for collisions and check the Layer they have.
  4. Índex the objects that are colliding and are on Enemies layer on the distance they have from the camera.

Hope it helps.