예제 #1
0
        /// <summary>
        /// Enter vehicle.
        /// </summary>
        /// <param name="vehicle">The vehicle to enter.</param>
        /// <param name="passenger">Is player entering vehicle as passenger?</param>
        public virtual void EnterVehicle(NetVehicle vehicle, bool passenger)
        {
            Client.Assert(currentVehicle == null, "Entered vehicle but player is already in vehicle.");
            Client.Assert(state == State.OnFoot, "Entered vehicle but player is not on foot.");

            // Set vehicle and put player inside it.

            currentVehicle = vehicle;
            currentVehicle.SetPlayer(this, passenger);

            SitInCurrentVehicle();

            // Set state of the player.

            SwitchState(passenger ? State.Passenger : State.DrivingVehicle);
        }
예제 #2
0
파일: NetPlayer.cs 프로젝트: kuppa213/MSCMP
        /// <summary>
        /// Enter vehicle.
        /// </summary>
        /// <param name="vehicle">The vehicle to enter.</param>
        /// <param name="passenger">Is player entering vehicle as passenger?</param>
        public virtual void EnterVehicle(NetVehicle vehicle, bool passenger)
        {
            Client.Assert(currentVehicle == null, "Entered vehicle but player is already in vehicle.");
            Client.Assert(state == State.OnFoot, "Entered vehicle but player is not on foot.");

            // Set vehicle and put player inside it.

            currentVehicle = vehicle;
            currentVehicle.SetPlayer(this, passenger);

            // Make sure player character is attached as we will not update it's position until he leaves vehicle.

            if (characterGameObject != null)
            {
                characterGameObject.transform.SetParent(currentVehicle.GameObject.VehicleTransform, false);
            }

            // Set state of the player.

            SwitchState(passenger ? State.Passenger : State.DrivingVehicle);
        }