Finding a Solution
A requested feature early-on in the FoodFight project was to have visual indicators pointing out where enemies and power-ups are located when they spawn. When it came time to implement them, there were a few things to consider:
- In virtual reality, all UI components need to be treated as objects in world space.
- Indicators would need to be put in a data container and created/destroyed as needed.
- A type of visor would be required that follows the user’s head and moves indicators as needed in real time.
- Was there a third party asset that could accomplish this?
Handling UI components in world space is nothing new. The same applies to creating basic data containers to make sure that indicators were spawning correctly. We already had a visor implemented that caused food to splatter when they came close to the player’s face, so maybe we could utilize that? We peaked at the Unity Asset Store to see if there was anything that offered a clean, cheap solution. Lo and behold, we found one. It’s called Off Screen Indicator (OSI) and it also works with virtual reality. Here was our solution, but it still took some work to get it right.
How it Works


Even though we had a visor and knowledge of world space UI canvases in Unity, there were other challenges involved. We would need a sprite for the indicators. Would they be arrows? Blips? The indicator itself would need to be offset from the user’s point of view. The indicator would also need to rotate to point to the correct position. What is the correct position? The Food Goblin’s legs? Head? Fortunately, these questions were solved with the asset and were built to be togglable from the Inspector window in Unity.
OSI has options for on and off screen indicators, meaning something will pinpoint an object that is already within the player’s view or point towards an object that isn’t. Power-Ups already have a glowing aura around them when they spawn, and Food Goblins stand out extremely well since they contrast with the environment and are large compared to other objects, so on-screen indicators were not needed. Since the player has free positional and rotational movement in VR they can sometimes not realize when an object is not within their view. We use sound effects to alert the player when power-ups or enemies have appeared, but we felt that a UI indicator pointing in the direction of an important object would help them find what they needed quickly without scrambling too much to figure out what was going on. OSI’s “visor” moves with the player and spawns in a list of sprites. Each sprite’s transform is tracked so it can be deleted if the object it is pointing to is deleted. However, we found that the asset wasn’t perfect and that not all transforms would be deleted correctly.

Adjusting for Food Fight
For single objects, OSI would delete their indicator no problem. However, if all objects needed to be wiped due to the player restarting the game they are in or returning to the main menu, the indicators would remain forever on the screen and would spit out an error stating that the object the indicator was tied to could no longer be tracked. OSI saved us a lot of time and headache, but it wasn’t perfect. A script was written to grab a list of all sprite transforms and wipe them before any other objects were deleted.
Finally, all that was left was setting up preferences for the indicators themselves. Indicators were color-coded depending on the object they were pointing at. Green was for power-ups and red for Food Goblins. A glow effect was added to make indicators stand out a bit more on the screen. Next was offsetting them so they weren’t in the middle of the player’s screen and blocking their view. It took some trial and error to find the sweet spot of where to place the indicators, but we settled on having them offset slightly off of the edge of the screen so that they were sort of in the player’s peripheral but didn’t cause their eyes to strain when looking for them.
Conclusion
We needed a proper indication system for Food Fight so that players have a visual cue for the location of power-ups and enemies. It needed to work with virtual reality and spawned on the fly. Off Screen Indicators is a third party asset on the Unity Store that accomplished this, but some additional scripts had to be made to make the asset more flexible for gameplay. However, it saved us much time and effort, because world space canvases make things more complex than a traditional canvas. With this system in place, we now have an indication system that can be edited as we see fit. More indicators can be added that signify more than power-ups or Food Goblins. Additionally, custom sprites can be added, colored, and overlaid with effects as we see fit. It benefits the developers to look at what is available by third-party vendors because you never know when someone has done a majority of the work for you.
You can read more about Food Fight on the game website, or download the game for free on the Oculus store.