Route Mapping to create a Safety Map for AI?

Hi, I am new to Unity and programming (not that new but unexperienced) and working on 2nd Unity tutorial; Space Shooter. I want to make an enemy ship AI to detect and avoid collisions with asteroids. To do that I thought of a safety map(as a minimap or another view/layer by a button) drawn considering asteroids routes with coloring. Here a view of scene:

And the map I want to make:

48234-map-sample.jpg

Note: I drew it like 3 objects spawned at the same time thats why coloring goes same with every route.

So, my initial idea is to calculate routes of every asteroid by their positions frame by frame when are instantiated and update when a collision occurs. Then coloring it relative to distance from the ship by updating every frame. Then make the ship move to safest area; primarily green areas, secondarily closer and lighter colored areas.

I believe I can figure navigation/AI out myself when I get the needed parameters or at least I want to, as fas as I can do, to challenge myself, learn/discover by myself. So my first objective and the part I need help is mapping.

For a clear recap; my goals are mapping routes of asteroids and coloring the map. If you can help me by giving ideas or some leads to follow, I appreciate. I am not sure which ways to follow, what to use as I am not well experienced. Atm efficiency is not much important as long as the solutions work. Thank you for at least reading this far and I apologise for my language and my bad expressions if I messed up.

I’ve done something a bit similar by adding a new layer, call it MiniMap, creating a camera that occludes everything but MiniMap, then occlude MiniMap on your main camera. Child the parent to the minimap UI root so you can move the map UI components anywhere and the camera will follow. Make the new camera an Ortho projection and rotate the camera so that it sits above and in front of your player ship and looks down on the field, just like you’d expect the map to look. Set the new camera’s Clear Flags to “Don’t Clear”, and adjust the ViewPort Rect to move it where you want it (0.5, 0.5) for x,y for instance to display it in the top right quadrant. That’s the setup.

The easiest approach is to create a new sphere object, set its layer to MiniMap, and attach it to the asteroid as a child object, so when the asteroid is being rendered in the main camera, the sphere is being rendered in the minimap camera.

Lastly, to compute the color, I would use the Color.Lerp function, to linearly interpolate between the yellow and red colors. It should naturally flow through orange this way and be smooth transitions (but if you want it to be stepped transitions as in your question, just clip the values you get back). You can choose the lerp from/to values to be basically 0 to 1. Then just compute the difference (radius) between the ship and the asteroid in display coordinates. Something like the Camera.worldToViewportPoint() method, called using the new camera’s instance. I would put that code right on the Sphere you use for the minimap, so you can easily adjust the color of whatever render material is assigned to that sphere.

EDIT: Sorry, re-read and realized I didn’t answer your question as far as mapping out the paths of the asteroids. You would still want a setup like this, but the way I would handle showing the current path of each asteroid is make that new sphere object in the minimap move forward along the route of the asteroid (just add asteroid.transform.forward * time.deltaTime * speed every frame to the sphere). I would then attach a particle system to the sphere and have it shoot out particles with colors that change based on their distance from the player’s ship. Lastly, I would do this in a loop, so the sphere shoots out at a high speed across the minimap, leaving a trail, then you reset the sphere to the asteroid and do it again. Would make a cool kind of radar look as the particles would fade out over time. Good luck!