Nameplates
Last updated
Was this helpful?
Last updated
Was this helpful?
In The M2 Example Plugin, we have an example component, BPC_M2Example_NameplateComponent
, which displays players' usernames over their heads, along with their recent chat messages.
Players in the rendering LOD 0 will have nameplates over their heads
Visibility checks are used to hide the nameplates of players that are blocked by scenery
The visibility checks run on a 1 second timer, so will not apply instantaneously as characters move e.g. behind scenery
The example's visibility checks are pretty simplistic, running a single line trace to the center of the character, so partially visible characters may or may not have nameplates visible
If players with nameplates move closer/further away, their nameplate will get larger/smaller
If players with nameplates send chat messages, they should appear over their heads.
BPC_M2Example_NameplateComponent
is a WidgetComponent
, attached to the BP_M2Example_PlayerCharacter
's head, the which displays a WBP_M2Example_Nameplate
widget.
The widget "distance" calculations are done in the component's tick, to update the scale of the widget based on how far away the player is from the camera.
If DistanceCullingEnabled
is true, this will also hide the widgets if their square distance is outside of VisibilityDistanceSqrd
.
The "visibility checking" is run in a separate timer at a lower interval (LOSTimerIntervalSeconds
)
To determine the local player's name, we need to use the "Profile data provider" world service (see World Services). This service is responsible for getting your player name from the web platform, and applying any name changes back to the web platform.
For other players to see your player name, we need to replicate that within Unreal. This is done in the BPMC_M2Example_PlayerNameComponent
.
The WBP_M2Example_NameplatePlayerName
widget (a widget within WBP_M2Example_Nameplate
) then listens to this replicated player name updating, to update the nameplate.
The nameplate listens to the unreal chat system outlined in Unreal Text Chat.
This is done in WBP_M2Example_NameplateMessagesContainer
- another widget within WBP_M2Example_Nameplate
.
The component needs to listen to the pooling events (see Actor Pooling), to make sure that the nameplate of the current actor reflects the correct corresponding Morpheus Actor.