Exemplo n.º 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);
        }
Exemplo n.º 2
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);

            // 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);
        }