Beispiel #1
0
    protected void Update()
    {
        Quaternion rotation;
        float      speed;

        if (floorDetector.floorRotation != null)
        {
            rotation = floorDetector.floorRotation.Value;
            speed    = lerpSpeedToFloor;
        }
        else
        {
            rotation = Quaternion.identity * Quaternion.Euler(0, 0, -1);;
            speed    = lerpSpeedWhileInAir;
        }

        if (turnAround.isFacingLeft)
        {
            rotation *= flipRotation;
        }

        if (floorDetector.DetectTheFloorWeAreStandingOn() == null)
        {
            return;
        }
        else
        {
            if (floorDetector.DetectTheFloorWeAreStandingOn().tag != "Enemy")
            {
                transform.rotation = Quaternion.Lerp(transform.rotation, rotation, speed * Time.deltaTime);
            }
        }
    }
Beispiel #2
0
 private void CheckIfCloseToPlayer()
 {
     distanceToPlayer = Vector3.Distance(playerController.transform.position, transform.position);
     if (floorDetector.DetectTheFloorWeAreStandingOn() == null)
     {
         return;
     }
     else
     {
         if (distanceToPlayer < characterXBounds || floorDetector.DetectTheFloorWeAreStandingOn().name == gameObject.name)
         {
             stopWalking = true;
             isRunning   = false;
         }
         else if (distanceToPlayer > characterXBounds * distanceToRunScaler)
         {
             stopWalking = false;
         }
     }
 }