示例#1
0
    /////////////////////////////////////////////////////////////////
    // Updates gameplay and physics
    /////////////////////////////////////////////////////////////////
    private void FixedUpdate()
    {
        if (obstacle != null)
        {
            Debug.DrawLine(playerObject.transform.position, hitPoint, debugColour, 0.01f);

            // Set hit point
            hitPoint = obstacle.GetComponent <Collider>().ClosestPoint(playerObject.transform.position);

            if (playerScript.GetMovementState() == MovementState.CLIMBING)
            {
                // Mantle after climbing
                if (playerObject.transform.position.y >= (GetTopEdge(obstacle).y - playerScript.GetCrouchHeight()) &&
                    playerObject.transform.position.y <= GetTopEdge(obstacle).y)
                {
                    playerScript.SetMovementState(MovementState.MANTLING);
                }
                // Face obstacle while climbing
                else
                {
                    playerObject.transform.LookAt(hitPoint);
                }
            }

            // Measure obstacle dimensions
            ObstacleCheck(obstacle);

            // Set action point if action started
            if (playerScript.ActionStarted())
            {
                // Face obstacle
                Vector3 lookPos = hitPoint - playerObject.transform.position;
                lookPos.y = 0.0f;
                playerObject.transform.rotation = Quaternion.LookRotation(lookPos);

                // Set points to move towards
                SetActionPoints();
            }
        }
    }