The motion tracker is a high cost equipment with a 25 meter range and 70 degrees view and it will alert the players of anything ahead of them and it's clearly inspired by Alien.
In my current project there are a variety of entities players can encounter including friendly,
a little hostile and VERY hostile ones.
Player doesn't know what's ahead. It can be your teammate, a friend or a foe... just that there is something.
Key design focus was to give players an expensive tool they can risk purchasing which can help them survive but it mostly seem to increase the tension, especially if the dot is approaching you...
Design
• A multi-sphere trace on pawn object type is performed. Object hit array is looped to check if the actor can be scanned with a blueprint interface, and add the scannable ones to a new array.
Filtering out actors outside the 70 degree field of view
1- On for each loop I do (ScannedActorLocation - PlayerActorLocation). In order to figure out where the scanned actor is relative to the player.
2- This vector is divided by it's length(normalized) as distance is not relevant.
3- Dot product is calculated with the normalized value and player characters forward vector.
4- I then check if the dot product value is greater then 0.342(cosine of 70°), and add the ones that return true to a new array. Effectively filtering out the ones that are not in 70 degrees field of view.
Screen Logic
• The screen is just a 3D widget attached to a static mesh.
• A 3D widgets maximum resolution can be 3840x2160(4K) which slightly complicates things because, the scan radius is 2500. So the 3D widget is 2160x2160 sized for maximum sharpness.
• After the scan is filtered previously, for each array element, a child widget that contains the dot image is spawned on an overlay on the main screen widget.
• After the scan is filtered previously, for each array element, a child widget that contains the dot image is spawned on an overlay on the main screen widget.
Vertical Screen Placement Calculation
1. Scanned actor locations distance to player actor location is calculated.
2. This value is then multiplied by 0.864. Because the actor can be 2500 units away while the widget is only 2160 units big and 2160 is exactly %13.6 smaller than 2500.
3- This value is then subtracted from 1080 because the entire widget is 2160 units long and I am calculating to place the child widget from the bottom, not the center.
This calculation is the render translation Y.
Horizontal Screen Placement Calculation
1- I get the right vector of the player actor and (scanned actor location - player actor location).
2- Do a dot product with the two values in step 1 but this time the I care about the distance so the values are not normalized.
3- This value is then again multiplied by 0.864 to account for the 2500 to 2160 ratio.
This calculation is the render translation X.
With both the X and Y calculated I can then use the "Set Render Translation" node to very accurately place the dot child widget on the overlay.
Appearance Delay
As you can see in the example above, dots appear after the scan line goes over them.
This effect is faked. The scan line is just an image moving from the bottom to the top of the widget in exactly 1 seconds.
Delay Logic
The dot child widget spawns as a hidden widget and has an exposed float variable for when it should be set to visible. On construction event with a delay, the widget is set to visible.
The delay length is calculated as (renderTranslation.Y - 1080) / 2500.