rolled back to 2021.3.1f1 due to a editor bug with dropdowns in inspector

This commit is contained in:
Mikolaj 2022-05-22 14:50:46 +02:00
parent 5dca464069
commit 0aaed2513b
5 changed files with 64 additions and 18 deletions

View file

@ -137,6 +137,9 @@ MonoBehaviour:
type: 3}
_spectatorBodyPrefab: {fileID: 1135382073684329176, guid: b615186e864b86245a99d5258f67ae27,
type: 3}
playerObjectList:
- playerGhost: {fileID: 0}
playerBody: {fileID: 0}
--- !u!54 &5298965799069515050
Rigidbody:
m_ObjectHideFlags: 0

View file

@ -1,11 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
namespace TTTSC.Player.Character.Controller
{
[RequireComponent(typeof(CharacterStateMachine))]
public class CharacterStateChanger : MonoBehaviour
public class CharacterStateChanger : NetworkBehaviour
{
private PlayerGhostReffrenceHub _playerGhostReffrenceHub;
private PlayerInputReceiver _playerInputReceiver;
@ -40,21 +41,40 @@ namespace TTTSC.Player.Character.Controller
private void Update()
{
if (_crouchIsHeld && !_sprintIsPerforming)
_characterStateMachine.movementStates = CharacterStateMachine.MovementStates.Crouching;
if (_walkIsPerforming && !_crouchIsHeld && !_sprintIsPerforming)
_characterStateMachine.movementStates = CharacterStateMachine.MovementStates.Walking;
if (_sprintIsPerforming && !_crouchIsHeld && _walkIsPerforming)
_characterStateMachine.movementStates = CharacterStateMachine.MovementStates.Sprinting;
if (!_walkIsPerforming && !_crouchIsHeld && !_sprintIsPerforming)
if (isLocalPlayer)
{
_characterStateMachine.movementStates = CharacterStateMachine.MovementStates.Idle;
Debug.Log("I am the local player");
if (_crouchIsHeld && !_sprintIsPerforming)
{
CmdCrouch();
}
if (_walkIsPerforming && !_crouchIsHeld && !_sprintIsPerforming)
_characterStateMachine.movementStates = CharacterStateMachine.MovementStates.Walking;
if (_sprintIsPerforming && !_crouchIsHeld && _walkIsPerforming)
_characterStateMachine.movementStates = CharacterStateMachine.MovementStates.Sprinting;
if (!_walkIsPerforming && !_crouchIsHeld && !_sprintIsPerforming)
{
_characterStateMachine.movementStates = CharacterStateMachine.MovementStates.Idle;
}
}
}
[Command]
void CmdCrouch()
{
RpcCrouch();
}
[ClientRpc]
void RpcCrouch()
{
_characterStateMachine.movementStates = CharacterStateMachine.MovementStates.Crouching;
}
}
}

View file

@ -32,8 +32,12 @@ namespace TTTSC.Player.Character.Controller
playerInputEvents.Enable();
_networkIdentity = GetComponent<NetworkIdentity>();
_networkIdentity.AssignClientAuthority(_networkIdentity.connectionToClient);
if (isServer)
{
_networkIdentity.AssignClientAuthority(_networkIdentity.connectionToClient);
}
//
#region GlobalControls

View file

@ -20,6 +20,15 @@ namespace TTTSC.Player.NetworkedCharacter
[SerializeField]
[Tooltip("assign the 'dead' prefab here")]
private GameObject _spectatorBodyPrefab;
[SerializeField]
private List<PlayerObject> playerObjectList;
[System.Serializable]
private class PlayerObject
{
public GameObject playerGhost;
public GameObject playerBody;
}
private GameObject _aliveBody;
private GameObject _spectatorBody;
@ -64,6 +73,16 @@ namespace TTTSC.Player.NetworkedCharacter
{
_aliveBody = Instantiate(_aliveBodyPrefab, transform.position, transform.rotation, transform);
NetworkServer.Spawn(_aliveBody);
GameObject _networkAliveBody = NetworkServer.spawned[(uint)NetworkServer.spawned.Count].gameObject;
Debug.Log("spawned alive body with ID " + _aliveBody.GetComponent<NetworkIdentity>().netId);
if (_networkAliveBody != null)
{
_networkAliveBody.transform.parent = transform;
}
}
}

View file

@ -1,2 +1,2 @@
m_EditorVersion: 2021.3.3f1
m_EditorVersionWithRevision: 2021.3.3f1 (af2e63e8f9bd)
m_EditorVersion: 2021.3.1f1
m_EditorVersionWithRevision: 2021.3.1f1 (3b70a0754835)