#Username Object
70 messages · Page 1 of 1 (latest)
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
@cyan crag sorry to @ you, respond whenever you're free but let me know if you could come up with something
So you should have only one camera in the game, the one for the local player. You can directly get that and follow it
should i delete the Camera Holder of other players then?
instead of disabling it
The Camera Holder is fine, you can just reference the main camera from the component
Or simply have a script on it
im not sure i understand
i already have a script on the Camera Holder which holds the Camera component
Simply put, you can get the Camera with Camera.main
It's easy then for the text to follow that
but i need OTHER cameras to follow that object
not my own
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
yeah, im trying to get the Username Canvas to rotate towards the Camera Holder
but not for me but for the other player
Right, there should be one Camera, have the text rotate to face it
so i can use Camera.main?
but i would have to remove the tag
from the ones i dont own
Again, there should only be one
so just delete the other one?
Even if just for the sake of performance
I'd recommend only creating one for the local player/grabbing it from the scene
so i can still keep my Camera Holder in my player prefab?
just remove the actual Camera from there
Yep
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
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
That should be good
its not setting the parent tho
Did you add code for that?
yup
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
What's that on?
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