Example #1
0
    void Update()
    {
        if (IsStopCar)
        {
            return;
        }
        Swipe();
        if (directCar == DirectCar.Left)
        {
            this.transform.position = Vector3.Lerp(this.transform.position, new Vector3(11.2f, this.transform.position.y, this.transform.position.z), SpeedDirect * Time.deltaTime);
        }
        if (directCar == DirectCar.Right)
        {
            this.transform.position = Vector3.Lerp(this.transform.position, new Vector3(-10.1f, this.transform.position.y, this.transform.position.z), SpeedDirect * Time.deltaTime);
        }

        WheelRF.Rotate(Vector3.forward * (Time.deltaTime * SpeedWheel * 10f));
        WheelLF.Rotate(Vector3.forward * (Time.deltaTime * SpeedWheel * 10f));
        WheelBL.Rotate(Vector3.forward * (Time.deltaTime * SpeedWheel * 10f));
        WheelBR.Rotate(Vector3.forward * (Time.deltaTime * SpeedWheel * 10f));
        UpdateMoveCar();
    }
Example #2
0
    private void Update()
    {
        if (!IsStopped)
        {
            if (Physics.Raycast(Ray.position, Ray.forward, out hit, 14f))
            {
                if (hit.collider)
                {
                    SpeedMove = 0;
                }
                else
                {
                    SpeedMove = StartSpeed;
                }
            }
            else
            {
                SpeedMove = StartSpeed;
            }
            if (IsSpeedCar)
            {
                if (Physics.Raycast(Ray.position, Ray.forward, out hit, 18f))
                {
                    if (hit.collider)
                    {
                        if (Reset == 0)
                        {
                            audioSource.clip = ClipFapFap;
                            audioSource.Play();
                            if (directCar == DirectCar.Right)
                            {
                                directCar = DirectCar.Left;
                            }
                            if (directCar == DirectCar.Left)
                            {
                                directCar = DirectCar.Right;
                            }
                            Reset = 1;
                            Invoke("InvokeReset", 1.8f);
                        }
                    }
                }

                if (directCar == DirectCar.Left)
                {
                    this.transform.position = Vector3.Lerp(this.transform.position, new Vector3(11.2f, this.transform.position.y, this.transform.position.z), SpeedDirect * Time.deltaTime);
                }
                if (directCar == DirectCar.Right)
                {
                    this.transform.position = Vector3.Lerp(this.transform.position, new Vector3(-10.1f, this.transform.position.y, this.transform.position.z), SpeedDirect * Time.deltaTime);
                }
            }
            switch (directionWorld)
            {
            case DirectionWorld.Forward:
                UpdateMoveCar(Vector3.forward);
                break;

            case DirectionWorld.Back:
                UpdateMoveCar(-Vector3.forward);
                break;
            }

            WheelRF.Rotate(Vector3.forward * (Time.deltaTime * SpeedWheel * 10f));
            WheelLF.Rotate(Vector3.forward * (Time.deltaTime * SpeedWheel * 10f));
            WheelBL.Rotate(Vector3.forward * (Time.deltaTime * SpeedWheel * 10f));
            WheelBR.Rotate(Vector3.forward * (Time.deltaTime * SpeedWheel * 10f));
        }
    }