コード例 #1
0
    private void FixedUpdate()
    {
        GetInput();
        Steer();

        int layerMask = 1 << 9;

        layerMask = ~layerMask;
        RaycastHit hit;

        Debug.DrawLine(transform.position, transform.position + (-Vector3.up * distToGround));
        if (!Physics.Raycast(transform.position, -Vector3.up, out hit, distToGround, layerMask))
        {
            //rb.AddForce(Vector3.down * Time.fixedDeltaTime * carGrav);
            return;
        }
        else if (Physics.Raycast(transform.position, -Vector3.up, out hit, distToGround, layerMask))
        {
            TerrainType tempTerrain = hit.transform.GetComponent <TerrainType>();
            if (tempTerrain != null)
            {
                if (TerrainType != tempTerrain.terrainTypePicker)
                {
                    tempTerrain.ChangeTerrainType(gameObject);
                }
            }
        }
        if (!finished)
        {
            if (verInput != 0f)
            {
                Accelerate();
            }
            else
            {
                Deaccelerate();
            }
            UpdateWheelPoses();
        }
        if (particleSystems.Length > 0)
        {
            if (verInput > .1f)
            {
                if (particleSystems[0].isStopped)
                {
                    for (int i = 0; i < particleSystems.Length; i++)
                    {
                        particleSystems[i].Play();
                    }
                }
            }
            else
            {
                if (particleSystems[0].isPlaying)
                {
                    for (int i = 0; i < particleSystems.Length; i++)
                    {
                        particleSystems[i].Stop();
                    }
                }
            }
        }
    }