Esempio n. 1
0
        private void Start()
        {
            if (!isLocalPlayer)
            {
                return;
            }

            PlayerBrain = GetComponent <PlayerBehaviour>();
            Ani         = GetComponent <Animator>();
        }
        void FixedUpdate()
        {
            if (!localPlayerAuthority)
            {
                enabled = false;
                return;
            }

            //DO A SEARCH FOR THE LOCAL PLAYER IF THE VARIABLE 'localPlayer' IS NULL
            if (localPlayer == null)
            {
                var players = GameObject.FindObjectsOfType <PlayerBehaviour>().ToList(); //GATHER EACH PLAYER

                players.ForEach(p =>
                {
                    if (p.localPlayerAuthority)
                    {
                        localPlayer = p;
                    }
                });
            }

            else
            {
                var driving = localPlayer.isDriving;

                if (driving)
                {
                    //ENABLE THE VEHICLE CAMERA, DISABLE THE PLAYER CAMERA
                    vehicleCam.gameObject.SetActive(true);
                    playerCam.gameObject.SetActive(false);

                    //ASSIGN THE CAMERA'S FOLLOW AND LOOK AT TARGETS TO THE TRANSFORM FROM 'localPlayer.vehicle'

                    vehicleCam.Follow = localPlayer.vehicle.transform;
                    vehicleCam.LookAt = localPlayer.vehicle.transform;
                }
                else
                {
                    //ENABLE THE PLAYER CAMERA, DISABLE THE VEHICLE CAMERA
                    playerCam.gameObject.SetActive(true);
                    vehicleCam.gameObject.SetActive(false);

                    //ASSIGN THE CAMERA'S FOLLOW AND LOOK AT TARGETS TO THE TRANSFORM FROM 'playerMovement'
                    playerCam.Follow = localPlayer.ic.transform;
                    playerCam.LookAt = localPlayer.ic.transform;
                }
            }
        }
        void FixedUpdate()
        {
            if (!localPlayerAuthority)
            {
                enabled = false;
                return;
            }

            var players = GameObject.FindObjectsOfType <PlayerBehaviour>().ToList();

            PlayerBehaviour player = null;

            players.ForEach(p =>
            {
                if (p.localPlayerAuthority)
                {
                    player = p;
                }
            });

            if (player != null)
            {
                var driving = player.isDriving;

                if (driving)
                {
                    vehicleCam.Follow = player.vehicle.transform;
                    vehicleCam.LookAt = player.vehicle.transform;

                    vehicleCam.gameObject.SetActive(true);
                    playerCam.gameObject.SetActive(false);
                }
                else
                {
                    playerCam.Follow = player.playerMovement.transform;
                    playerCam.LookAt = player.playerMovement.transform;

                    playerCam.gameObject.SetActive(true);
                    vehicleCam.gameObject.SetActive(false);
                }
            }
        }
Esempio n. 4
0
 [ClientRpc] public void RpcRemovePlayer()
 {
     seatedPlayer = null;
 }
Esempio n. 5
0
 [ClientRpc] public void RpcSetPlayer(NetworkIdentity playerNetworkIdentity)
 {
     seatedPlayer = playerNetworkIdentity.GetComponent <PlayerBehaviour>();
 }
Esempio n. 6
0
 [Command] public void CmdRemovePlayer()
 {
     seatedPlayer = null;
     RpcRemovePlayer();
 }
Esempio n. 7
0
 [Command] public void CmdSetPlayer(NetworkIdentity playerNetworkIdentity)
 {
     seatedPlayer = playerNetworkIdentity.GetComponent <PlayerBehaviour>();
     RpcSetPlayer(playerNetworkIdentity);
 }