Jogador não esta sendo validado em rede multijogador
Página 1 de 1
Jogador não esta sendo validado em rede multijogador
Boa noite pessoal, estou trabalhando com a rede Mirror Network, e estou tendo um problema na hora de instanciar o jogador na cena, acaba que o jogador instancia, mas não valida os seus scripts, no entanto os mantem desativados ao invés de ativar...
Script do Player:
Script do Player:
- Código:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
public class PlayerNetwork : NetworkBehaviour
{
private Camera _MainCamera;
private FPSPlayer _FPSPlayerComponent;
private FPSRigidBodyWalker _FPSWalker;
private Ironsights _Ironsights;
private InputControl _InputControl;
private DragRigidbody _DragRigibody;
private PlayerWeapons _PlayerWeapons;
private GunSway _GunSway;
private WeaponEffects _WeaponEffects;
private CamAndWeapAnims _CamAndWeapAnims;
private ReconfigurePrefab _ReconfigurePrefab;
private SmoothMouseLook _SmoothMouseLook;
private Footsteps _Foootsteps;
private MovePlayerAndCamera _MovePlayerAndCamera;
private PlayerCharacter _PlayerCharacter;
private CameraControl _CameraControl;
private WeaponPivot _WeaponPivot;
void Awake()
{
_MainCamera = Camera.main;
}
void OnValidate()
{
if (_CamAndWeapAnims == null)
_CamAndWeapAnims = GetComponentInChildren<CamAndWeapAnims>();
if (_ReconfigurePrefab == null)
_ReconfigurePrefab = GetComponentInChildren<ReconfigurePrefab>();
if (_SmoothMouseLook == null)
_SmoothMouseLook = GetComponentInChildren<SmoothMouseLook>();
if (_Foootsteps == null)
_Foootsteps = GetComponentInChildren<Footsteps>();
if (_CameraControl == null)
_CameraControl = GetComponentInChildren<CameraControl>();
if (_FPSPlayerComponent == null)
_FPSPlayerComponent = GetComponentInChildren<FPSPlayer>();
if (_FPSWalker == null)
_FPSWalker = GetComponentInChildren<FPSRigidBodyWalker>();
if (_Ironsights == null)
_Ironsights = GetComponentInChildren<Ironsights>();
if (_InputControl == null)
_InputControl = GetComponentInChildren<InputControl>();
if (_DragRigibody == null)
_DragRigibody = GetComponentInChildren<DragRigidbody>();
if (_PlayerWeapons == null)
_PlayerWeapons = GetComponentInChildren<PlayerWeapons>();
if (_GunSway == null)
_GunSway = GetComponentInChildren<GunSway>();
if (_WeaponEffects == null)
_WeaponEffects = GetComponentInChildren<WeaponEffects>();
if (_PlayerCharacter == null)
_PlayerCharacter = GetComponentInChildren<PlayerCharacter>();
if (_WeaponPivot == null)
_WeaponPivot = GetComponentInChildren<WeaponPivot>();
_CamAndWeapAnims.enabled = false;
_ReconfigurePrefab.enabled = false;
_SmoothMouseLook.enabled = false;
_CameraControl.enabled = false;
_FPSWalker.enabled = false;
_FPSPlayerComponent.enabled = false;
_Ironsights.enabled = false;
_InputControl.enabled = false;
_DragRigibody.enabled = false;
_PlayerWeapons.enabled = false;
_GunSway.enabled = false;
_WeaponEffects.enabled = false;
_PlayerCharacter.enabled = false;
_WeaponPivot.enabled = false;
//_MovePlayerAndCamera.enabled = false;
GetComponent<Rigidbody>().isKinematic = true;
GetComponent<NetworkTransform>().clientAuthority = true;
}
// Start is called before the first frame update
public override void OnStartLocalPlayer()
{
_CamAndWeapAnims.enabled = true;
_ReconfigurePrefab.enabled = true;
_SmoothMouseLook.enabled = true;
_CameraControl.enabled = true;
_FPSWalker.enabled = true;
_FPSPlayerComponent.enabled = true;
_Ironsights.enabled = true;
_InputControl.enabled = true;
_DragRigibody.enabled = true;
_PlayerWeapons.enabled = true;
_GunSway.enabled = true;
_WeaponEffects.enabled = true;
_PlayerCharacter.enabled = true;
_WeaponPivot.enabled = true;
//_MovePlayerAndCamera.enabled = true;
if (isLocalPlayer)
{
if (_MainCamera != null)
{
_MainCamera.enabled = true;
}
}
}
public override void OnStopLocalPlayer()
{
if (isLocalPlayer)
{
if (_MainCamera != null)
{
_MainCamera.enabled = false;
}
}
}
// Update is called once per frame
void Update()
{
if (!isLocalPlayer
|| _CamAndWeapAnims == null
|| !_CamAndWeapAnims.enabled
|| _ReconfigurePrefab == null
|| !_ReconfigurePrefab.enabled
|| _SmoothMouseLook == null
|| !_SmoothMouseLook.enabled
|| _Foootsteps == null
|| !_Foootsteps.enabled
|| _CameraControl == null
|| !_CameraControl.enabled
|| _FPSWalker == null
|| !_FPSWalker.enabled
|| _Ironsights == null
|| !_Ironsights.enabled
|| _InputControl == null
|| !_InputControl.enabled
|| _DragRigibody == null
|| !_DragRigibody.enabled
|| _PlayerWeapons == null
|| !_PlayerWeapons.enabled
|| _GunSway == null
|| !_GunSway.enabled
|| _WeaponEffects == null
|| !_WeaponEffects.enabled
|| _PlayerCharacter == null
|| !_PlayerCharacter.enabled
|| _WeaponPivot == null
|| !_WeaponPivot.enabled)
return;
}
void FixedUpdate()
{
if (!isLocalPlayer
|| _CamAndWeapAnims == null
|| !_CamAndWeapAnims.enabled
|| _ReconfigurePrefab == null
|| !_ReconfigurePrefab.enabled
|| _SmoothMouseLook == null
|| !_SmoothMouseLook.enabled
|| _Foootsteps == null
|| !_Foootsteps.enabled
|| _CameraControl == null
|| !_CameraControl.enabled
|| _FPSWalker == null
|| !_FPSWalker.enabled
|| _Ironsights == null
|| !_Ironsights.enabled
|| _InputControl == null
|| !_InputControl.enabled
|| _DragRigibody == null
|| !_DragRigibody.enabled
|| _PlayerWeapons == null
|| !_PlayerWeapons.enabled
|| _GunSway == null
|| !_GunSway.enabled
|| _WeaponEffects == null
|| !_WeaponEffects.enabled
|| _PlayerCharacter == null
|| !_PlayerCharacter.enabled
|| _WeaponPivot == null
|| !_WeaponPivot.enabled)
return;
}
}
Tópicos semelhantes
» Quando o objeto esta sendo gerado ele esta rotacionando
» Desconectar jogador após acabar o tempo de jogo utilizando a rede - Bolt
» Using UnityEngine.UI não esta sendo reconhecido
» as sombras da minha sena esta sendo renderizadas longe de aonde deveria começar
» Porque meu objeto não está sendo ativado? unity 2D
» Desconectar jogador após acabar o tempo de jogo utilizando a rede - Bolt
» Using UnityEngine.UI não esta sendo reconhecido
» as sombras da minha sena esta sendo renderizadas longe de aonde deveria começar
» Porque meu objeto não está sendo ativado? unity 2D
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos