Example #1
0
    /// <summary>
    /// Move passenger by given displacement
    /// </summary>
    public void Move(Vector2 displacement, bool standingOnPlatform)
    {
        PassengerMover passengerMover = gameObject.GetComponent <PassengerMover>();

        if (passengerMover)
        {
            passengerMover.CalculatePassengerMovement(displacement);

            passengerMover.MovePassengers(true);
            MoveTarget(displacement);
            passengerMover.MovePassengers(false);
        }
        else
        {
            MoveTarget(displacement);
        }
    }
    void Update()
    {
        if (globalWaypoints.Length > 0)
        {
            Vector3 displacement = CalculatePlatformMovement();

            if (passengerMover)
            {
                passengerMover.CalculatePassengerMovement(displacement);

                passengerMover.MovePassengers(true);
                transform.Translate(displacement);
                passengerMover.MovePassengers(false);
            }
            else
            {
                transform.Translate(displacement);
            }
        }
    }