private void Start()
    {
        transform_m = GetComponent<Transform>();

        navMeshAgent = GetComponent<NavMeshAgent>();
        if (navMeshAgent == null)
        {
            navMeshAgent = gameObject.AddComponent<NavMeshAgent>();
            navMeshAgent.height = 2f;
            navMeshAgent.stoppingDistance = 1f;
        }
        navMeshAgent.enabled = true;

        rigidBody = GetComponent<Rigidbody>();
        if (rigidBody == null)
        {
            rigidBody = gameObject.AddComponent<Rigidbody>();
            rigidBody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
        }
        rigidBody.isKinematic = true;

        ev_Audio = GetComponent<EventoAudio>();
        if (ev_Audio == null)
            ev_Audio = gameObject.AddComponent<EventoAudio>();

        audioZona = GetComponent<AudioZona>();
        if (audioZona == null)
            audioZona = gameObject.AddComponent<AudioZona>();

        animatore = GetComponent<Animator>();
        capsula = GetComponent<CapsuleCollider>();
        altezzaCapsula = capsula.height;
        capsulaCentro = new Vector3(0.0f, capsula.center.y, 0.0f);
        IsPointAndClick = true;
        layerAlberi = ~layerAlberi;
        switchVivoMorto = GetComponent<SwitchVivoMorto>();
        if (!Statici.inGioco)
            return;
        DatiPersonaggio = GetComponent<DatiPersonaggio>();

        if (!Statici.multigiocatoreOn)
        {
            Statici.RegistraDatiPersonaggio(DatiPersonaggio);
            //se all'inizio della partita si ritrova a 0 di vita, gli do 1 di vita così non nasce morto.
            if (DatiPersonaggio.Vita <= 0f)
            {
                DatiPersonaggio.Vita = 1f;
                SalvaDatiVita();
            }
        }
        else
        {

            managerNetwork = GameObject.Find("ManagerNetwork").GetComponent<ManagerNetwork>();
            gestoreCanvas = GameObject.Find("ManagerCanvasMultiplayer").GetComponent<GestoreCanvasNetwork>();
        }
    }
    private void Start()
    {
        transform_m = GetComponent<Transform>();

        navMeshAgent = GetComponent<NavMeshAgent>();
        if (navMeshAgent == null)
        {
            navMeshAgent = gameObject.AddComponent<NavMeshAgent>();
            navMeshAgent.height = 2f;
            navMeshAgent.stoppingDistance = 1f;
        }
        navMeshAgent.enabled = true;

        rigidBody = GetComponent<Rigidbody>();
        if (rigidBody == null)
        {
            rigidBody = gameObject.AddComponent<Rigidbody>();
            rigidBody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
        }
        rigidBody.isKinematic = true;

        ev_Audio = GetComponent<EventoAudio>();
        if(ev_Audio == null)
            ev_Audio = gameObject.AddComponent<EventoAudio>();

        audioZona = GetComponent<AudioZona>();
        if (audioZona == null)
            audioZona = gameObject.AddComponent<AudioZona>();

        animatore = GetComponent<Animator>();
        capsula = GetComponent<CapsuleCollider>();
        altezzaCapsula = capsula.height;
        capsulaCentro = new Vector3(0.0f, capsula.center.y, 0.0f);
        IsPointAndClick = true;
        layerAlberi = ~layerAlberi;
        if (SceneManager.GetActiveScene().buildIndex == 0)
            return;
        datiPersonaggio = GetComponent<DatiPersonaggio>();
        GameManager.RegistraDatiPersonaggio(datiPersonaggio);
    }