Adding Encounter Visuals
This is where our previous work in the Marking Out the Route section comes into play. Recall that as our CargoUnit
falls through its trajectory, it is constantly laying down a line of breadcrumbs to mark out its path. This is visualized by the CargoUnit.trailMesh
component, which other than needing to be initialized and disposed of during scenario resets, takes care of itself without much need for us to intervene. We need an equivalently hands-off way to similarly render visualizations for encounters when and where they occur along the route, and that’s precisely what the work we just covered is meant to enable.
Important note:
While the following section is ultimately cut from the game, the technique demonstrated is helpful to have in your pocket.
Putting 2D Labels into 3D Space
Although there is a 3D GUI system in Babylon.js, our current needs don’t require the use of a full 3D UI. Still, one of the advantages of a 3D GUI is that...