Closed WHHM98 closed 3 months ago
Hello¡ Thank you very much for buying the book, I am very happy to know that you are liking it. I'm going to check the problem you are telling me about and try to help you as much as I can. Best regards!
Hello friend¡ Please, can you share your DisableUnneededScriptsForOtherPlayers.cs class code ?
Also note when two players are instantiated, check if the player with the problem has the Third Person Controller or Player Input components. It is possible that one of them has been removed during the process of the DisableUnneededScriptsForOtherPlayers.cs class.
I did not change the scripts at all and they are exactly the same as the repository scripts. DisableUnneededScriptsForOtherPlayers.cs:
using System.Collections;
using System.Collections.Generic;
using Photon.Pun;
using StarterAssets;
using UnityEngine;
public class DisableUnneededScriptsForOtherPlayers : MonoBehaviourPun
{
void Start()
{
//We search for all components or GameObjects that can create interference with our player.
PhotonView photonView = GetComponent<PhotonView>();
CharacterController character = GetComponent<CharacterController>();
ThirdPersonController controller = GetComponent<ThirdPersonController>();
OVRPlayerController controllerVR = GetComponent<OVRPlayerController>();
Transform camera = transform.parent.Find("Main Camera");
Transform ovrCameraRig = transform.Find("OVRCameraRigWithControllers");
Transform playerFollowCamera = transform.parent.Find("PlayerFollowCamera");
Transform geometryParent = transform.Find("Geometry");
Transform mobileController = transform.parent.Find("UI_Canvas_StarterAssetsInputs_Joysticks");
if (!photonView.IsMine)
{
gameObject.tag = "Untagged";
//If not us, we delete all GameObjects and Components that we have searched for before.
if (mobileController)
{
Destroy(mobileController);
}
if (controller != null)
{
Destroy(controller);
}
if (controllerVR != null)
{
Destroy(controllerVR);
}
if (character != null)
{
Destroy(character);
}
if (camera != null)
{
Destroy(camera.gameObject);
}
if (ovrCameraRig != null)
{
Destroy(ovrCameraRig.gameObject);
}
if (playerFollowCamera != null)
{
Destroy(playerFollowCamera.gameObject);
}
}
else
{
gameObject.tag = "Player";
// We add the GameObject Geometry and its descendants to a specific layer that will allow us to filter it in the Camera.
var transparentLayer = LayerMask.NameToLayer("TransparentFX");
SetLayerAllChildren(geometryParent, transparentLayer);
}
void SetLayerAllChildren(Transform root, int layer)
{
var children = root.GetComponentsInChildren<Transform>(includeInactive: true);
foreach (var child in children)
{
// Debug.Log(child.name);
child.gameObject.layer = layer;
}
}
}
}
Player with the problem has both of Third Person Controller and Player Input components but the player with ability to move has only player input component.
I am sending you the errors of my console after player 2 join, maybe it can help to solve the problem:Error1:"Cannot load scene: Invalid scene name (empty string) and invalid build index -1 UnityEngine.SceneManagement.SceneManager:LoadSceneAsync (string) NetworkManager:OnJoinedRoom () (at Assets/_App/Scripts/NetworkManager.cs:142) Photon.Realtime.MatchMakingCallbacksContainer:OnJoinedRoom () (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:4203) Photon.Realtime.LoadBalancingClient:OnEvent (ExitGames.Client.Photon.EventData) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3236) ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PeerBase.cs:899) ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/EnetPeer.cs:583) ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PhotonPeer.cs:1771) Photon.Pun.PhotonHandler:Dispatch () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:226) Photon.Pun.PhotonHandler:FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:145) ", Error2:"Can't remove RectTransform because Canvas depends on it", Error3:"'Remote p#1 v#1' AnimationEvent 'OnFootstep' on animation 'Walk_N' has no receiver! Are you missing a component?"
Hello David. I know you're busy, and I'm sorry. Did you find a way to solve this issue?
Yes! Let me write you tomorrow with the fix, thanks!!
El dom, 24 dic 2023, 21:27, WHHM98 @.***> escribió:
Hello David. I know you're busy, and I'm sorry. Did you find a way to solve this issue?
— Reply to this email directly, view it on GitHub https://github.com/PacktPublishing/Build-Your-Own-Metaverse-with-Unity/issues/1#issuecomment-1868588584, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEZ73PA63XMAIWSPPFOFMWLYLCFZPAVCNFSM6AAAAABA5ZLSN6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRYGU4DQNJYGQ . You are receiving this because you commented.Message ID: <PacktPublishing/Build-Your-Own-Metaverse-with-Unity/issues/1/1868588584@ github.com>
Thank you very much.
Hello friend, I have downloaded the project repository in a clean directory, it works perfectly both players online.
Can you check which scenes you have added in Build Settings?
Yes, that's right, the players are online, but can both players move? Always the second player who joins the main game scene freezes for me and can't move at all :( in addition my build settings exactly are same. Is it okay if I send you a video from time of extraction of the repository zip file until showing its problems?
Yes, in my case I can move both players.
Have you noticed that the unity editor freezes? or is it just the player and everything else works?
I want to rule out that it is a code problem
Can you attach your project in a zip?
Hi David. I hope you are well. I had a cold for a while and could not send you a message. I downloaded the repository zip file again and took a video from extracting the zip file to the moment of encountering the error and sent it to you. I think this video can solve my problem with your help. But if there is a need for further investigation, I will definitely send my project files. Thank you for helping me. I wish the best for you.
Hello friend, I have been testing:
I have cloned the repository, completely deleted everything related to Firebase and i have been able to play with both players connected. In your video, I see that you get errors, related to Firebase, I have tried to do the same as you and I also get the errors.
The conclusion may be that the Firebase plugin is not correct in the repository. I suggest you to follow these steps to rule out:
Thank you very much for your patience
Hello David. I did what you said, but unfortunately, Unity got stuck in the endless loop of compiling the project and I have a new problem. In addition, i don't understand what you mean about sandbox mode. Do you mean sandbox mode, the same as safe mode?
Hello! Share your email with me, I will send you a wetransfer with s version of the project, we will try it
El vie, 5 ene 2024, 11:46, WHHM98 @.***> escribió:
Hello David. I did what you said, but unfortunately, Unity got stuck in the endless loop of compiling the project and I have a new problem. In addition, i don't understand what you mean about sandbox mode. Do you mean sandbox mode, the same as reset mod?
— Reply to this email directly, view it on GitHub https://github.com/PacktPublishing/Build-Your-Own-Metaverse-with-Unity/issues/1#issuecomment-1878471171, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEZ73PFBQKB5MICWZYVVKW3YM7K2FAVCNFSM6AAAAABA5ZLSN6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZYGQ3TCMJXGE . You are receiving this because you commented.Message ID: <PacktPublishing/Build-Your-Own-Metaverse-with-Unity/issues/1/1878471171@ github.com>
thank you. I sent you my email in Telegram.
The reader contacted me via Telegram and together we found the solution to the problem, please contact me at @davidcanton if the same thing happened to yo
Hello. This repository was very useful for me. Thank you very much. I saw only two problems while running the game, which I would appreciate if you could help to fix. The first problem is that in the simultaneous presence of two players in the main scene of the game, the player who joined as the first player can always move, but the second player who joins the main scene after the first player, is completely frozen and cannot move at all. The second problem was that when I built the Windows version of the project and play it, I went to world 1 and acquired that house, but when I opened the browser and pressed the copy button, nothing happened and the transaction was not completed at all. I would be very grateful if you could solve the two mentioned problems.