Пример #1
0
    public void Reset()
    {
        // start in fall state
        FSM.ChangeState(FallState);

        // used for bunnyhop avoidance
        JumpKeyReleased = true;

        // reset velocity
        rigidbody.velocity        = Vector3.zero;
        rigidbody.angularVelocity = Vector3.zero;

        // Reset player and objects according to check point
        if (LastCheckpoint == null)
        {
            Debug.Log("Only happens at the start of each level");
            // reset player position
            transform.position = startTransform.position;
        }
        else
        {
            Checkpoint check = LastCheckpoint.GetComponent <Checkpoint>();
            if (check != null)
            {
                check.loadCheckpoint(transform);
            }
            else
            {
                // reset player position
                transform.position = startTransform.position;
            }
        }
    }