#Username Object

70 messages · Page 1 of 1 (latest)

idle cedar
#

hey, my problem is that i have the Username Canvas attached to my players head and i have no idea how to make it rotate to the others players camera

#

in my player prefab im also holding the Camera Holder

#

which has a script on it that disables that object if your not the owner

#

so how would i go about making the Username Canvas on some OTHER player rotate towards your camera, below you can see i tried something but its not quite working for all players
https://hastebin.com/share/iqohupowar.csharp

idle cedar
#

@cyan crag sorry to @ you, respond whenever you're free but let me know if you could come up with something

cyan crag
idle cedar
#

instead of disabling it

cyan crag
#

The Camera Holder is fine, you can just reference the main camera from the component

#

Or simply have a script on it

idle cedar
#

im not sure i understand

#

i already have a script on the Camera Holder which holds the Camera component

cyan crag
#

Simply put, you can get the Camera with Camera.main

#

It's easy then for the text to follow that

idle cedar
#

not my own

cyan crag
#

The cameras don't follow, the text does

#

Remember, there should only be one actual camera

#

For the local player

#

That's why it's best to have the camera start in the scene or instantiated at run-time

idle cedar
#

yeah, im trying to get the Username Canvas to rotate towards the Camera Holder

#

but not for me but for the other player

cyan crag
#

Right, there should be one Camera, have the text rotate to face it

idle cedar
#

so i can use Camera.main?

#

but i would have to remove the tag

#

from the ones i dont own

cyan crag
#

Again, there should only be one

idle cedar
#

so just delete the other one?

cyan crag
#

Even if just for the sake of performance

cyan crag
idle cedar
#

so i can still keep my Camera Holder in my player prefab?

#

just remove the actual Camera from there

cyan crag
#

Yep

idle cedar
#

yeah that makes more sense

#

cause i still need my Camera Holder to be networked

#

im holding a head target in there for example of where the head ik should look

#

and that has a network transform

idle cedar
#

so just have this

#

and then i can just parent it to the Camera Holder?

#

when the player spawns

#

by just grabbing Camera.main

#

something like this

#

and then i can simply make the text rotate towards Camera.main since there is only 1

#

does that look right then?

#

there is only 1 camera now, and it gets parented to the Camera Holder when the game starts

idle cedar
#

its not setting the parent tho

cyan crag
#

Did you add code for that?

idle cedar
#
private void Initialize()
{
    if (IsOwner)
    {
        Transform cam = Camera.main.transform;
        Debug.Log(cam);
        cam.SetParent(CameraHolder);

        cam.localPosition = Vector3.zero;
        cam.localRotation = Quaternion.identity;
        cam.localScale = Vector3.one;
    }
    else
    {
        gameObject.SetActive(false);
    }
}```
#

i placed a debug to see if its finding it and it is

idle cedar
#

my Camera Holder

#

in the PlayerCameraController script

#

and Initialize is called in OnStartClient

#

if i put it in start it works

#

but i cant have it in start

#

oh

#

its because my "loading" scene has a camera as well

#

and its grabbing that one

#

because my scene manager first loads the new scene THEN unloads the loading scene

#

yup now its working

#

i removed the camera from my loading scene and my bootstrap scene

#

cause they were getting destroyed, just too late