Ejemplo n.º 1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        bool isTouchingGround = CarManager.CheckGround(2.5f);

        if (isTouchingGround)
        {
            TimeSinceLanded += Time.deltaTime;
        }
        else
        {
            TimeSinceLanded = 0f;
        }

        if (Input)
        {
            Joystick.Update();

            float mag       = Joystick.GetMagnitude() / 20f;
            float roadWidth = LevelGenerator.instance.RoadWidth / 2f;

            CarManager.MoveSideways(PlayerPos.x + mag);

            if (isTouchingGround)
            {
                CarManager.Torque = 0f;

                if (CarManager.Flips > 0 && TimeSinceLanded < 1.5f)
                {
                    StartCoroutine(BoostPlayer());
                }

                CarManager.Flips = 0;
                CarManager.MoveForward();
            }
            else
            {
                CarManager.Rotate();
            }
        }
    }
Ejemplo n.º 2
0
    private void SetPositionOnDistance()
    {
        float mag = Joystick.GetMagnitude() / InputSensitivity;


        Quaternion rot = Track.GetRotationAtDistance(Dist);

        Player.rotation    = Quaternion.Euler(rot.eulerAngles.x, rot.eulerAngles.y, 0f);
        transform.rotation = Quaternion.Lerp(transform.rotation, Track.GetRotationAtDistance(Dist), CameraRotationSmoothing * Time.deltaTime);
        transform.rotation = Quaternion.Euler(transform.eulerAngles.x, transform.eulerAngles.y, 0f);

        Move = Track.GetPointAtDistance(Dist) + Vector3.up / 10f;
        transform.position = Move;

        Move = PlayerPos + Vector3.right * mag;
        Player.localPosition = Vector3.MoveTowards(Player.localPosition, Move, SideSpeed * Time.deltaTime);
        Player.localPosition = Vector3.ClampMagnitude(Player.localPosition, 3.5f);


        Car.position = Vector3.MoveTowards(Car.position, Player.position, Time.deltaTime * Speed);
        Car.LookAt(Player.position);
    }