예제 #1
0
    void MovePlatform()
    {
        if (canMove)
        {
            transform.position = Vector3.MoveTowards(transform.position, movePoint.position, smoothMovement);
            if (Vector3.Distance(transform.position, movePoint.position) <= halfDistance)
            {
                if (!smoothMovementHalfed)
                {
                    smoothMovement      /= 2f;
                    smoothMovementHalfed = true;
                }
            }

            if (Vector3.Distance(transform.position, movePoint.position) == 0f) // platform reached its destination
            {
                canMove = false;
                if (smoothMovementHalfed)
                {
                    smoothMovement       = initialMovement;
                    smoothMovementHalfed = false;
                }
                // deactivate doors
                if (deactivateDoors)
                {
                    doorController.OpenDoors();
                }
                // stop sfx
                soundFx.PlayAudio(false);
            }
        }
    }
예제 #2
0
 public void ActivateRotation()
 {
     if (!canRotate)
     {
         canRotate = true;
         soundFx.PlayAudio(true);
         // deactivate rotation
         Invoke("DeactivateRotation", deactivateTimer);
     }
 }