Ejemplo n.º 1
0
        public void UpdatePosition(Vector3 position, Vector3 velocity, Quaternion bodyRotation, Quaternion aimingRotation, Optional <string> opSubGuid)
        {
            body.SetActive(true);

            SubRoot subRoot = null;

            if (opSubGuid.IsPresent())
            {
                string subGuid = opSubGuid.Get();
                Optional <GameObject> opSub = GuidHelper.GetObjectFrom(subGuid);

                if (opSub.IsPresent())
                {
                    subRoot = opSub.Get().GetComponent <SubRoot>();
                }
                else
                {
                    Console.WriteLine("Could not find sub for guid: " + subGuid);
                }
            }

            SetVehicle(null);
            SetPilotingChair(null);
            SetSubRoot(subRoot);

            rigidBody.velocity        = animationController.Velocity = MovementHelper.GetCorrectedVelocity(position, velocity, body, PlayerMovement.BROADCAST_INTERVAL);
            rigidBody.angularVelocity = MovementHelper.GetCorrectedAngularVelocity(bodyRotation, body, PlayerMovement.BROADCAST_INTERVAL);

            animationController.AimingRotation         = aimingRotation;
            animationController.UpdatePlayerAnimations = true;
        }
Ejemplo n.º 2
0
        public void UpdatePosition(Vector3 position, Vector3 velocity, Quaternion bodyRotation, Quaternion aimingRotation)
        {
            Body.SetActive(true);

            // When receiving movement packets, a player can not be controlling a vehicle (they can walk through subroots though).
            SetVehicle(null);
            SetPilotingChair(null);

            RigidBody.velocity        = AnimationController.Velocity = MovementHelper.GetCorrectedVelocity(position, velocity, Body, PlayerMovement.BROADCAST_INTERVAL);
            RigidBody.angularVelocity = MovementHelper.GetCorrectedAngularVelocity(bodyRotation, Vector3.zero, Body, PlayerMovement.BROADCAST_INTERVAL);

            AnimationController.AimingRotation         = aimingRotation;
            AnimationController.UpdatePlayerAnimations = true;
        }
Ejemplo n.º 3
0
        public void UpdatePosition(Vector3 position, Vector3 velocity, Quaternion bodyRotation, Quaternion aimingRotation)
        {
            Body.SetActive(true);

            // When receiving movement packets, a player can not be controlling a vehicle (they can walk through subroots though).
            SetVehicle(null);
            SetPilotingChair(null);
            // If in a subroot the position will be relative to the subroot
            if (SubRoot != null && !SubRoot.isBase)
            {
                Quaternion vehicleAngle = SubRoot.transform.rotation;
                position = vehicleAngle * position;
                position = position + SubRoot.transform.position;
            }
            RigidBody.velocity        = AnimationController.Velocity = MovementHelper.GetCorrectedVelocity(position, velocity, Body, PlayerMovement.BROADCAST_INTERVAL);
            RigidBody.angularVelocity = MovementHelper.GetCorrectedAngularVelocity(bodyRotation, Vector3.zero, Body, PlayerMovement.BROADCAST_INTERVAL);

            AnimationController.AimingRotation         = aimingRotation;
            AnimationController.UpdatePlayerAnimations = true;
        }
Ejemplo n.º 4
0
        public void UpdatePosition(Vector3 position, Vector3 velocity, Quaternion bodyRotation, Quaternion aimingRotation, Optional <string> opSubGuid)
        {
            Body.SetActive(true);

            SubRoot subRoot = null;

            if (opSubGuid.IsPresent())
            {
                GameObject sub = GuidHelper.RequireObjectFrom(opSubGuid.Get());
                subRoot = sub.GetComponent <SubRoot>();
            }

            // When receiving movement packets, a player can not be controlling a vehicle (they can walk through subroots though).
            SetVehicle(null);
            SetPilotingChair(null);
            SetSubRoot(subRoot);

            RigidBody.velocity        = AnimationController.Velocity = MovementHelper.GetCorrectedVelocity(position, velocity, Body, PlayerMovement.BROADCAST_INTERVAL);
            RigidBody.angularVelocity = MovementHelper.GetCorrectedAngularVelocity(bodyRotation, Vector3.zero, Body, PlayerMovement.BROADCAST_INTERVAL);

            AnimationController.AimingRotation         = aimingRotation;
            AnimationController.UpdatePlayerAnimations = true;
        }
Ejemplo n.º 5
0
        public void UpdatePlayerPosition(string playerId, Vector3 position, Quaternion rotation, Optional <String> opSubGuid)
        {
            GameObject player = GetPlayerGameObject(playerId);

            player.SetActive(true);

            if (opSubGuid.IsPresent())
            {
                String subGuid = opSubGuid.Get();
                Optional <GameObject> opSub = GuidHelper.GetObjectFrom(subGuid);

                if (opSub.IsPresent())
                {
                    player.transform.parent = opSub.Get().transform;
                }
                else
                {
                    Console.WriteLine("Could not find sub for guid: " + subGuid);
                }
            }

            MovementHelper.MoveGameObject(player, position, rotation, PLAYER_TRANSFORM_SMOOTH_PERIOD);
        }
Ejemplo n.º 6
0
        public void UpdatePosition(Vector3 position, Quaternion bodyRotation, Quaternion cameraRotation, Optional <string> opSubGuid)
        {
            body.SetActive(true);
            if (opSubGuid.IsPresent())
            {
                string subGuid = opSubGuid.Get();
                Optional <GameObject> opSub = GuidHelper.GetObjectFrom(subGuid);

                if (opSub.IsPresent())
                {
                    body.transform.parent = opSub.Get().transform;
                }
                else
                {
                    Console.WriteLine("Could not find sub for guid: " + subGuid);
                }
            }

            MovementHelper.MoveGameObject(body, position, PLAYER_TRANSFORM_SMOOTH_PERIOD);
            MovementHelper.RotateGameObject(playerView, cameraRotation, PLAYER_TRANSFORM_SMOOTH_PERIOD);

            animationController.AimingRotation = cameraRotation;
        }