Make usernames face camera at runtime

Hello! I have a text gameobject attached to the Player object. How do I turn the other players text objects towards my camera at runtime? (So their names are always readable).
Solution:
I have figured it out and I am honestly a tiny bit ashamed. It was simply executing the code from the wrong game object (game manager). I had the transform.LookAt code together with the code that fills in the username at runtime. The only thing I had to do is attach the transform.LookAt code to the display name object and that obviously fixed the issue.. Thanks again for the help! I will just hide under a rock for a while 😂 Have a great weekend!
Jump to solution
27 Replies
kapa.ai
kapa.ai6mo ago
Hi @Hippolicious || CardaStacks. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. The provided knowledge sources do not contain specific information on how to make text objects attached to the Player object face the camera at runtime. However, you might find it helpful to review the Normcore Documentation (https://normcore.io/documentation/), which provides comprehensive information on various aspects of the NormalVR platform. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai6mo ago
<@366873530199179264> kapa.ai is still learning and improving, please let us know how it did by reacting below
Hippolicious || CardaStacks
@Normcore Assistant How do I sync the transform component of a gameobject?
kapa.ai
kapa.ai6mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- To synchronize the transform component of a GameObject in NormalVR, you can use the RealtimeTransform component. Here are the steps: 1. Create an empty scene. Add a Realtime component to an empty game object and configure the appKey so it can connect. 2. Create a GameObject in the scene and add a RealtimeTransform component to it. 3. Export a build, and open it next to the editor. Hit Play in Unity. 4. Click the "Request Ownership" button on the RealtimeTransform inspector (not the RealtimeView inspector). 5. Drag the GameObject around in the scene and watch how it updates on the build automatically. The RealtimeTransform component has several properties that you can set to control what aspects of the transform are synchronized: - syncTransform: If true, the transform will sync its position, rotation, and scale with the model. - syncPosition: If true, the transform will sync its position with the model. - syncRotation: If true, the transform will sync its rotation with the model. - syncScale: If true, the transform will sync its scale with the model. - syncVelocity: If true, the rigidbody on this transform will sync its velocity with the model. - syncAngularVelocity: If true, the rigidbody on this transform will sync its angular velocity with the model. Remember, if you want to move an object, you need to request ownership of it. If you're not the owner, the datastore values are treated as the source of truth. For more information, check out the guide on RealtimeTransform (https://normcore.io/documentation/realtime/realtimetransform) and Synchronizing a GameObject (https://normcore.io/documentation/realtime#synchronizing-a-gameobject) in the Normcore Documentation. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai6mo ago
<@366873530199179264> kapa.ai is still learning and improving, please let us know how it did by reacting below
Hippolicious || CardaStacks
That is a great answer! I will compare my code with the documentation.
maxweisel
maxweisel6mo ago
Fwiw, I don't think you want to use RealtimeTransform to sync the nametag rotation as it will be facing a different camera for each player. I don't think you'll want to use networking for that to be honest. @Normcore Assistant Without using Normcore, do you know how to use Unity to billboard a game object to face the camera?
kapa.ai
kapa.ai6mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- I'm sorry, but as an AI developed for NormalVR, I'm only able to provide information based on the provided knowledge sources, which are all related to the Normcore platform. I don't have the ability to provide information or instructions outside of these sources. For information on how to billboard a game object to face the camera in Unity without using Normcore, I recommend checking Unity's official documentation or community forums. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai6mo ago
<@353762082451095552> kapa.ai is still learning and improving, please let us know how it did by reacting below
maxweisel
maxweisel6mo ago
@Hippolicious || CardaStacks would be worth asking ChatGPT that question. I'm sure you'll get a solid answer. But in short, you want the nametag gameobject to billboard to face the active camera inside of LateUpdate(). That will ensure it looks correct for all players.
Hippolicious || CardaStacks
Ok thanks I will give it a try 😊🙏
Mechabit
Mechabit6mo ago
you can use lookat to make the name text face the camera https://docs.unity3d.com/ScriptReference/Transform.LookAt.html
Hippolicious || CardaStacks
Yes that works for your own avatar but can't make it work for other players that is why I thought it was a multiplayer issue. Maybe I should reference the new initiated players's name objects differently...
Mechabit
Mechabit6mo ago
how I do it is put lookat script on my avatar prefab and then target mainCamera mainCamera being different on every local client you might be targeting the remote avatar which would make all the name tags point at themselves if you get me e.g. void LateUpdate(){ transform.LookAt(Camera.main.transform.position); }