Tuesday, 16 May 2017

Mini Map/Map Screen

I decided a good addition to the UI would be an on-screen mini map, and a real-time map screen.

These are both achieved in a similar way and use the same objects for both.

I started by creating a copy of the actual game map under the level, just without any roof pieces to allow for overhead cameras (this is important).

I made the walls black so that they would show up more clearly on the map screens.



For the mini-map, I needed a camera that would follow the position of the player on the map and clearly show the position.

I created a blueprint object with a green arrow piece and a camera with a render target pointing down on it attached.



This blueprint simply updates it's own  position based on where the player character is located (minus the depth at which the duplicate map is positioned).



And for tracking enemies, there is a similar red arrow blueprint, but the difference is that these objects are actually passive and do not have any code in themselves. They are spawned by each enemy when they are created, then receive their position from the enemy itself as it moves around.

And here's the code inside the enemies that communicate with the objects. You can see that when they are spawned they are assigned to a variable which is then used as the target for the positional updates.



For the main map screen, I just have another camera in the world with a scene capture that can see the whole map. All of the tracker objects from the mini map are visible which allows the user to see their own position, enemies and health pickups.

You can see both of these maps in action in the screen shot below. Notice how the mini-map rotates with the player character and the main map shows everything in relative position.

No comments:

Post a Comment