• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by Wesley21spelde · Jan 20, 2021 at 02:53 AM · multiplayertagsnameissues

player name tags not always facing camera of every client (PhotonNetwork)

hey guys i tried to get this working but no luck i am using photon network and i wanted all my other players name tags to face me in my client and with the other players the other way arround so my UIText will face them in their client i did post a simular post befour but didnt think it was clear what i wanted i have this script on the canvas that is above the characters /players is thare a way of doing this ?.. also i put in the if statement so when thare are no players accept me it wil not bug and if i have only my client no bug but as soon as i startup an other client it say refference not set to an instance of an object becouse it can`t find a main camera here is the script

 public class BilBord_Face_Camera : MonoBehaviour
 {
     private Transform mainCameraTransform;
 
     private void Start()
     {
         mainCameraTransform = Camera.main.transform;
     }
 
     private void LateUpdate()
     {
         if(mainCameraTransform == null)
         {
 
         }
         else
         {
             transform.LookAt(transform.position + mainCameraTransform.rotation * Vector3.forward,
             mainCameraTransform.rotation * Vector3.up);
         }
 
     }
     
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by madhavarora · Jan 28 at 05:23 PM

Having the same problem. Were you able to solve it? @Wesley21spelde

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Wesley21spelde · Jan 28 at 07:00 PM 0
Share

actualy yes are you using Photon unity Networking? my solution was to make a if photonview is $$anonymous$$e like this.. ill share my code... ................................................................................................................................ using System.Collections; using UnityEngine.UI; using UnityEngine;

 public class Player_Name_Tag : Photon.MonoBehaviour
 {
     public Text m_MyText;
     public GameObject target;
     
 
     public void Awake()
     {
         
         m_MyText.GetComponent<Text>().text = photonView.owner.NickName;
     }
     void Update()
     {
         if (photonView.isMine)
         {
             
         }
         else
         {
             target = GameObject.FindWithTag("Player");
 
             transform.parent.transform.LookAt(target.transform);
         }
     }
 }

i will explaine how i did this to begin i am the only Player who`s tag is player. by default my player prefab is a tag player but i dont want everyone to be taged player only your self on your clienet so someone else should be also taged player but only at their end in their clienet i used for this a same method with the photonview is$$anonymous$$e so if it is do nothing and else so if i am on someone els`s clienet change my tag to enemy. this way you are always the only one taged as player than i used the code above to say if photonview is $$anonymous$$e do nothing but if you are someone els look at me (player. you can also see i did a transform.parent becouse in my case my text was fliped and the code is on the text so i did the rotation on the parent and it fixed my text it is now looking at me the right way and not backwards. i hope it works for you too if you still have any questions ill help you where i can

avatar image madhavarora Wesley21spelde · Jan 28 at 07:07 PM 0
Share

Using mirror, although i did manage to get an extremely simple solution. Add a script to the text object

 using UnityEngine;
 
 public class NameFaceCamera : MonoBehaviour
 {
     void Update()
     {
         transform.LookAt(Camera.main.transform);
         transform.Rotate(0, 180, 0);
     }
 }

This works because there is only one camera inside the scene. Scratched my head trying to solve this in the most complex way and then finally realised how simple it actually was.

avatar image Wesley21spelde madhavarora · Jan 28 at 07:31 PM 0
Share

yeah same here :D what kind of game are u making ?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

240 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiplayer Game Networking Layer Problem 0 Answers

[UNET/JS] How to enable local player controll 0 Answers

Unity2D: UNET transport layer API server script isn't messaging properly 0 Answers

can i add multiplayer as the last thing i do when making game app? 2 Answers

How do I get health of another networked player? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges