示例#1
0
    /// <summary>
    /// Called when the script is called and initializes the battle script for
    /// this script.
    /// </summary>
    void Start()
    {
        masterBattleScript = GameObject.Find(MASTER_BASE_LOOP).
                             GetComponent <MasterBaseScript>();

        actualCamera = transform.Find(ACTUAL_CAMERA).gameObject;
        if (actualCamera == null)
        {
            Debug.LogError("The camera could not be found in "
                           + gameObject.name);
        }

        playerCameraController = GetComponent <CharacterController>();
    }
    /// <summary>
    /// Start is called before the first frame and gets all the needed
    /// components from the puppet, its children and the scene.
    /// </summary>
    void Start()
    {
        // Find the master battle script component. Return an error if it is
        // not found.
        masterBattleScript =
            GameObject.Find(MASTER_BATTLE_LOOP).
            GetComponent <MasterBaseScript>();
        if (masterBattleScript == null)
        {
            Debug.LogError("Master Battle Script could not be found!");
        }

        // Find the destination indicator. Return and error if it is not found,
        //  otherwise, un-child it and disable it.
        destinationIndicator = transform.Find(DESTINATION_INDICATOR).gameObject;
        if (destinationIndicator == null)
        {
            Debug.LogError("The Destination Object could not be found in " +
                           gameObject.name);
        }
        else
        {
            destinationIndicator.transform.parent = null;
            enableDestinationIndicator(false);
        }

        // Find the nav mesh agent and remove updated rotation.
        navMeshAgent = GetComponent <NavMeshAgent>();
        navMeshAgent.updateRotation = false;

        // Create a new mesh path for the passive path line to calcualte the
        // predicted movement of the puppet.
        path = new NavMeshPath();

        // Find the line renderer and set its width and position count.
        pathLineRenderer               = GetComponent <LineRenderer>();
        pathLineRenderer.startWidth    = linePathWidth;
        pathLineRenderer.endWidth      = pathLineRenderer.startWidth;
        pathLineRenderer.positionCount = 0;

        // Find the main player camera. If it couldnt be found, throw an error.
        player = Camera.main.gameObject;
        if (player == null)
        {
            Debug.LogError("There is no main camera!");
        }
    }