private void FixedUpdate()
    {
        if (Helper.Abs(currentVel.magnitude) < Helper.Abs(terminalVel) && falling) //Hasn't reached terminal velocity, keep accelerating
        {
            currentVel += acceleration;
        }
        else   //Has reached terminal velocity, stop accelerating
        {
        }

        if (falling)
        {
            transform.Translate(currentVel * physicsTime);
        }
    }
예제 #2
0
    private void FixedUpdate()
    {
        RaycastHit hit;

        if (Physics.Raycast(new Vector3(pos.x, pos.y, pos.z), Vector3.down, out hit, 0.01f + Helper.Abs(lowestY)))   //Ray hit either under or inside GO
        {
            float hitDist = Vector3.Distance(hit.point, pos);
            if (hitDist >= lowestY && !onFloor) //Hit under (GO is on or near the ground)
            {
                onFloor = true;
                HitFloor();
                //Debug.Log(gameObject.name + " hit the floor.");
            }
            else if (hitDist < lowestY && onFloor)  //GO is phasing through ground
            {
                MovingUp();
                //Debug.Log(gameObject.name + ": Floor is moving up and through me.");
            }
            else if (hitDist >= lowestY && onFloor)  //Still on floor, do nothing
            {
            }
            else
            {
                Debug.Log("I broke the FLoorCheck.");
            }
        }
        else if (onFloor)
        {
            onFloor = false;
            LeftFloor();
        }
    }