top of page
Search
  • Writer's pictureРостислав Кейван

On-screen target indicator

Indicators on the screen are an important part of probably every game, take this as the standard of the gaming industry, if we are talking about AAA games, then you need this mechanic. The indicator on the screen indicates the player about the possible actions that are available to him, first of all, notify him of interaction with the game object, it can also be if the player is lost in the game environment, the designation of enemies, etc.


Take for example games like

  • Uncharted

  • Tomb Rider Lara Croft

  • Last of Us

Before starting development, my research was on these 3 games


Uncharted 3: Drake's Deception

Uncharted 3: Drake's Deception

 

Shadow of the Tomb Rider

Shadow of the Tomb Rider

 

Last of Us 2

Last of Us 2

 


In my project, I developed a similar mechanic, let's take a look.



Demonstration: Indicator on the screen

 


The Object has a point in space, for a general understanding, I marked it red, this is the center of the object's coordinates. I abandoned the distance calculation and used triggers, a small opportunity for optimization. For each trigger, I created an event and which causes us the desired one.


When the scene is initialized, the object loads the Date container (Scriptable Object), which in turn checks which device is connected, Dualshock, Oculus Touch, XBox gamepad, it doesn’t matter, after the engine loads the sprite (canvas) with the necessary keys, which are stored in variables


Let's get acquainted with my implementation and analyze in more detail

There are 3 zones in total, in which the indicator appears.

  • Zone 1 - The player is outside the trigger, if the player crosses it an indicator will appear, I used linear interpolation, and passed the color there using a coroutine. After that, it checks if the player is in this zone, if yes then we return to Vector3 a world space point created by transforming a screen space point at a given distance z from the camera plane. Here's the Camera.ScreenToWorldPoint function that converts a point from screen space to world space, where world space is defined as the coordinate system at the very top of your game's hierarchy. World space coordinates can still be calculated even if provided as off-screen coordinates, for example to instantiate an off-screen object near a certain corner of the screen.


  • Zone 2 - The player is outside of Zone 2 if the player crosses it there will be an indicator of the desired button to press, here is the same interpolation in action, I call this zone "Interaction Zone" as we show tooltips or icons for the player. If the player exits zone 2, the key icon will disappear.


  • Zone 3 - The player is outside of Zone 3, if the player crosses it, the indicator and button indicator will disappear. I did this in order to avoid visual noise on the screen, if the player is close to the object, we turn off all indicators.


Implementation theory

 


2 views0 comments

Recent Posts

See All
bottom of page