PUN Basics Tutorial: 9 - Player UI Prefab
1.
In the "Following the Target Player" section the next code
wouldn't work because Renderer is attached to a child element, not to the root. So, we have to write
--------------------------------
2.
In the same section the next code
In the "Following the Target Player" section the next code
targetRenderer = this.target.GetComponent<Renderer>();
wouldn't work because Renderer is attached to a child element, not to the root. So, we have to write
targetRenderer = this.target.GetComponentInChildren<Renderer>();
--------------------------------
2.
In the same section the next code
void LateUpdate() { // Do not show the UI if we are not visible to the camera, thus avoid potential bugs with seeing the UI, but not the player itself. if (targetRenderer != null) { this.gameObject.SetActive(targetRenderer.isVisible); } if (targetTransform != null) { targetPosition = targetTransform.position; targetPosition.y += characterControllerHeight; this.transform.position = Camera.main.WorldToScreenPoint(targetPosition) + screenOffset; } }wouldn't work too because once gameObject is set inactive the LateUpdate method wouldn't be called anymore (see MonoBehaviour.LateUpdate()).
0
Comments
-
Hi @develax,
This is expected in the early stages of the development phase where you test using two clients.
The server will receive the 2nd client's join random room request before finishing the creation of the room created by the first client. You should wait before starting the 2nd client or calling join random room.0 -
Hi @JohnTube,
in order not to create confusion, I have created a separate discussion for this issue.
0 -
Hi,
Doing this isn't going to be enough, I am it, trying to find the best way to tackle this case.
Bye,
Jean0 -
Hi @jeanfabre,
if you mean hiding player UI, I think this should work:if (_targetRenderer.isVisible) transform.SetParent(_canvas.GetComponent<Transform>()); // Show UI. else transform.SetParent(null); // Hide UI.
0 -
Hi,
I went for using CanvasGroup, which gives you more potential for animation, and a greater control, but yes, that should work too.
Bye,
Jean
0