Photon transform view not syncing despite other objects transform view working perfectly
So Im making a little multiplayer game using photon pun, I'm new to photon but everything is quite simple. A player gets spawned in via a 'player spawner' GameObject which has this script attached to it:
using Cinemachine;
using Photon.Pun;
using UnityEngine;
namespace Photon
{
public class PlayerSpawner : MonoBehaviour
{
[SerializeField] private GameObject playerPrefab = null;
[SerializeField] private Transform playerCamera = null;
private void Start()
{
var player = PhotonNetwork.Instantiate(playerPrefab.name, Vector3.zero, Quaternion.identity);
playerCamera.SetParent(player.transform); //This stuff just sets up some fields
playerCamera.GetComponent<PlayerLook>().playerBody = player.transform;
playerCamera.GetComponent<PlayerLook>().weaponBody = player.transform.Find("Weapon");
}
}
}
It spawns in both players and the players both have transform views, again really simple. I literally just dragged in the rigidbody and transform of the player into the photon transform.
When running, the other player just falls out of the map and its transform isn't synced. The position fluctuates from around -750 to -1000. The player can spawn bullets as well, which works just fine, and that transform is synced between the two clients. So I don't understand what is happening since the bullet has the same transform sync. What's even weirder is this happened randomly, it used to work completely fine. It happen when I was doing something else and I'm not sure how to fix it. I would really appreciate any ideas. Here is a screenshot of the bullets (the blue things ) working any the other player falling out of the world .
][1]
Sorry if this was confusing and complicated and thanks for any help. I have been stuck on this for a while. I also already checked out other questions but If I missed someone with a similar problem to mine, please link it. Thanks so much. ,So Im making a little multiplayer game using photon pun, I'm new to photon but everything is quite simple. A player gets spawned in via a 'player spawner' gameobject which has this script attached to it:
using Cinemachine;
using Photon.Pun;
using UnityEngine;
namespace Photon
{
public class PlayerSpawner : MonoBehaviour
{
[SerializeField] private GameObject playerPrefab = null;
[SerializeField] private Transform playerCamera = null;
private void Start()
{
var player = PhotonNetwork.Instantiate(playerPrefab.name, Vector3.zero, Quaternion.identity);
playerCamera.SetParent(player.transform); //This stuff just sets up some fields
playerCamera.GetComponent<PlayerLook>().playerBody = player.transform;
playerCamera.GetComponent<PlayerLook>().weaponBody = player.transform.Find("Weapon");
}
}
}
It spawns in both players and the players both have transform views, again really simple. I literally just dragged in the rigidbody and transform of the player into the photon transform.
When running, the other player just falls out of the map and its transform isn't synced. The position fluctuates from around -750 to -1000. The player can spawn bullets as well, which works just fine, and that transform is synced between the two clients. So I don't understand what is happening since the bullet has the same transform sync. Whats even weirder is this happened randomly, it used to work completely fine. It happen when I was doing something else and I'm not sure how to fix it. I would really appreciate any ideas. At the bottom is a screenshot of the bullets (the blue things ) working any the other player falling out of the world .
Sorry if this was confusing and complicated and thanks for any help. I have been stuck on this for a while. I also already checked out other questions but If I missed someone with a similar problem to mine, please link it. Thanks so much.
Answer by rehaanpunjabi · Jan 11, 2020 at 08:28 AM
WOW I'm stupid. I just forgot to add the photon transform view to each child (the weapon and the body mesh). If anyone is having that problem check the children have the photon transform view already.
Your answer
Follow this Question
Related Questions
PhotonUnity player move object problem ! 1 Answer
Racing game using PUN 2 0 Answers
Synchronize an INT through Photon Pun2 0 Answers