- Home /
Photon Unity multiplayer player name issue (worldtoscreenpoint?)
So basically i've been working on a simple multiplayer first person shooter game. So far i've done the map, spawning, movement and currently i'm working on player names. I've almost finished and player names appear above the characters, however theres one issue which I would like to fix.
When i look at another player in the game, their name appears above their head. However, when i turn away from the player the name appears like a reflection on the other side in the distance. I've come to think the issue is the world to screen point function used. What is actually going on when the other players aren't in view? does the function stop working or does it keep trying to show the name. If this is the problem how can i fix it?
I'm using photon by the way to code this.
Here is my name tag code which is placed on the player prefab:
using UnityEngine;
using System.Collections;
public class Nametag : MonoBehaviour {
void OnGUI()
{
Vector3 offset = new Vector3(0,1, 0); // height above the target position
Vector3 point = Camera.main.WorldToScreenPoint(transform.position + offset);
point.y = Screen.height - point.y;
GUI.Label(new Rect(point.x - 40 , point.y, 200, 20), GetComponent<PhotonView> ().owner.name);
}
}
Your answer
Follow this Question
Related Questions
Photon Network Muzzleflash 0 Answers
[PHOTON PUN] Players cant shoot each other? 1 Answer
please help multiplayer question(photon). 1 Answer
Problem with UFPS and photon 1 Answer
Photon Networking Instantiating Problem 0 Answers