Hello all,
I’m trying to find a good way to see my teammates through walls by displaying an indicator around them.
I’m thinking this belongs on each player’s HUD, and then I can loop through all other players in an update function, and get their coordinates, translate to local viewport coords, and display something there.
I might be along the right track, but implementing it is another story (rather new to Unity). Any advice, or working examples would be much appreciated ![]()
Edit: Thinking now that I would need to instantiate some sort of object at the local viewport coordinates for each player on my team. Still any examples would be appreciated!
Edit 2: What I’m doing now is in an OnGUI() method:
public void OnGUI()
{
if(Game.IsTeamBased)
{
foreach(var player in Game.PlayerScripts)
{
if(player != this player.TeamNum == this.TeamNum)
{
var playerCoords = player.transform.position;
var screenCords = mFPCamera.WorldToScreenPoint(playerCoords);
GUI.Label(new Rect(screenCords.x, screenCords.y, 40, 20), player.Statistics.Name);
}
}
}
}
This has some problems though.
- The coordinates look to be wrong. Some text is statically just sitting still on screen.
- My game supports up to 4 player split screen, and I’m thinking the screen coordinates given back by each player’s FPCamera don’t account for this.