cant force other playrs to perform animation

So the main problem with this script is its suppose to force the object the sword hits to perform various animations but of course nothing happens instead. what edits do i need to force the object the sword hits to properly perform the animation?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;

public class Gettindamaged : NetworkBehaviour
{
    public GameObject player;
    [SyncVar]
    public bool candamage;
    public GameObject targeting;
    [SyncVar]
    public bool noshield;
    public Animator anim;


    void OnTriggerEnter(Collider other)

    {
        anim = other.gameObject.GetComponent<Animator>();
        if (!isLocalPlayer)
            return;

        if (candamage == true && other.gameObject.tag.Contains("Enemy") && noshield == false)
        {
            Debug.Log(other.gameObject);
            //defemce
            if (candamage == true && player.GetComponent<Attackdirection>().attacknumber == other.gameObject.GetComponent<AIattackdirection>().attacknumber && other.GetComponent<Stats>().sword.GetComponent<AIdoesdamage>().noshield == false)
            {
                Debug.Log("defence");
                if (player.GetComponent<Attackdirection>().attackingleft == true && other.gameObject.GetComponent<AIattackdirection>().attackingleft == true)
                {

                    Cmd_Animatenemy("blockedleft");
                    Cmd_Animate("parriedleft");
                    other.GetComponent<Stats>().shield.GetComponent<Stats>().takingdamage(1);

                }
                if (player.GetComponent<Attackdirection>().attackingup == true && other.gameObject.GetComponent<AIattackdirection>().attackingup == true)
                {
                    Cmd_Animatenemy("blockedup");
                    Cmd_Animate("parriedup");
                    other.GetComponent<Stats>().shield.GetComponent<Stats>().takingdamage(1);


                }
                if (player.GetComponent<Attackdirection>().attackingright == true && other.gameObject.GetComponent<AIattackdirection>().attackingright == true)
                {
                    Cmd_Animatenemy("blockedright");
                    Cmd_Animate("parriedright");
                    other.GetComponent<Stats>().shield.GetComponent<Stats>().takingdamage(1);


                }
                if (player.GetComponent<Attackdirection>().attackingdown == true && other.gameObject.GetComponent<AIattackdirection>().attackingdown == true)
                {
                    Cmd_Animatenemy("blockeddown");
                    Cmd_Animate("parrieddown");
                    other.GetComponent<Stats>().shield.GetComponent<Stats>().takingdamage(1);


                }

               
            }



            //attack
            if (candamage == true && player.GetComponent<Attackdirection>().attacknumber != other.gameObject.GetComponent<AIattackdirection>().attacknumber || other.GetComponent<Stats>().sword.GetComponent<AIdoesdamage>().noshield == true && candamage == true)
            {
                Debug.Log("attack");
                if (player.GetComponent<Attackdirection>().attackingleft == true && other.gameObject.GetComponent<AIattackdirection>().attackingleft == false || other.GetComponent<Stats>().sword.GetComponent<AIdoesdamage>().noshield == true)
                {
                    Cmd_Animatenemy("gethit");
                    other.gameObject.GetComponent<Stats>().takingdamage(player.GetComponent<Stats>().damage);


                }
                if (player.GetComponent<Attackdirection>().attackingup == true && other.gameObject.GetComponent<AIattackdirection>().attackingup == false || other.GetComponent<Stats>().sword.GetComponent<AIdoesdamage>().noshield == true)
                {
                    Cmd_Animatenemy("gethit");
                    other.gameObject.GetComponent<Stats>().takingdamage(player.GetComponent<Stats>().damage);

                }
                if (player.GetComponent<Attackdirection>().attackingright == true && other.gameObject.GetComponent<AIattackdirection>().attackingright == false || other.GetComponent<Stats>().sword.GetComponent<AIdoesdamage>().noshield == true)
                {
                    Cmd_Animatenemy("gethit");
                    other.gameObject.GetComponent<Stats>().takingdamage(player.GetComponent<Stats>().damage);

                }
                if (player.GetComponent<Attackdirection>().attackingdown == true && other.gameObject.GetComponent<AIattackdirection>().attackingdown == false || other.GetComponent<Stats>().sword.GetComponent<AIdoesdamage>().noshield == true)
                {
                    Cmd_Animatenemy("gethit");
                    other.gameObject.GetComponent<Stats>().takingdamage(player.GetComponent<Stats>().damage);

                }
            }

                candamage = false;
        }






        //player
        if (candamage == true && other.gameObject.tag.Contains("player") && other.gameObject != player.gameObject && other.GetComponent<Stats>().sword.GetComponent<Gettindamaged>().noshield == false)
        {

            if (candamage == true && player.GetComponent<Attackdirection>().attacknumber == other.gameObject.GetComponent<Attackdirection>().attacknumber)
            {

                if (player.GetComponent<Attackdirection>().attackingleft == true && other.gameObject.GetComponent<Attackdirection>().attackingleft == true)
                {
                    Cmd_Animatenemy("blockedleft");
                    Cmd_Animate("parriedleft");
                    other.GetComponent<Stats>().shield.GetComponent<Stats>().takingdamage(1);

                }
                if (player.GetComponent<Attackdirection>().attackingup == true && other.gameObject.GetComponent<Attackdirection>().attackingup == true)
                {
                    Cmd_Animatenemy("blockedup");
                    Cmd_Animate("parriedup");
                    other.GetComponent<Stats>().shield.GetComponent<Stats>().takingdamage(1);


                }
                if (player.GetComponent<Attackdirection>().attackingright == true && other.gameObject.GetComponent<Attackdirection>().attackingright == true)
                {
                    Cmd_Animatenemy("blockedright");
                    Cmd_Animate("parriedright");
                    other.GetComponent<Stats>().shield.GetComponent<Stats>().takingdamage(1);


                }
                if (player.GetComponent<Attackdirection>().attackingdown == true && other.GetComponent<Attackdirection>().attackingdown == true)
                {
                    Cmd_Animatenemy("blockeddown");
                    Cmd_Animate("parrieddown");
                    other.GetComponent<Stats>().shield.GetComponent<Stats>().takingdamage(1);


                }
            }


            if (candamage == true && player.GetComponent<Attackdirection>().attacknumber != other.gameObject.GetComponent<Attackdirection>().attacknumber && other != player.gameObject || other.GetComponent<Stats>().sword.GetComponent<Gettindamaged>().noshield == true && candamage == true && other != player.gameObject)
            {
                if (player.GetComponent<Attackdirection>().attackingleft == true && other.gameObject.GetComponent<Attackdirection>().attackingleft == false)
                {
                    Cmd_Animatenemy("gethit");
                    other.gameObject.GetComponent<Stats>().takingdamage(player.GetComponent<Stats>().damage);


                }
                if (player.GetComponent<Attackdirection>().attackingup == true && other.gameObject.GetComponent<Attackdirection>().attackingup == false || other.GetComponent<Stats>().sword.GetComponent<Gettindamaged>().noshield == true)
                {
                    Cmd_Animatenemy("gethit");
                    other.gameObject.GetComponent<Stats>().takingdamage(player.GetComponent<Stats>().damage);

                }
                if (player.GetComponent<Attackdirection>().attackingright == true && other.gameObject.GetComponent<Attackdirection>().attackingright == false || other.GetComponent<Stats>().sword.GetComponent<Gettindamaged>().noshield == true)
                {
                    Cmd_Animatenemy("gethit");
                    other.gameObject.GetComponent<Stats>().takingdamage(player.GetComponent<Stats>().damage);

                }
                if (player.GetComponent<Attackdirection>().attackingdown == true && other.gameObject.GetComponent<Attackdirection>().attackingdown == false || other.GetComponent<Stats>().sword.GetComponent<Gettindamaged>().noshield == true)
                {
                    Cmd_Animatenemy("gethit");
                    other.gameObject.GetComponent<Stats>().takingdamage(player.GetComponent<Stats>().damage);

                }
            }

            candamage = false;
        }
    }




    [Command]
    void Cmd_Animate(string trigger)
    {
        Rpc_Animate(trigger);
    }

    [ClientRpc]
    void Rpc_Animate(string trigger)
    {
        player.GetComponent<Animator>().SetTrigger(trigger);
    }



    [Command]
    void Cmd_Animatenemy(string trigger)
    {
        Rpc_Animateenemy(trigger);
    }

    [ClientRpc]
    void Rpc_Animateenemy(string trigger)
    {
        anim.SetTrigger(trigger);
    }



    // Use this for initialization
    void Start () {

    }
   
    // Update is called once per frame
    void Update () {
       
    }
}

Hmm. Might be a dumb question but
where do Cmd_Animatenemy and Rpc_Animateenemy methods get pointer to enemy in question?
Or his animator, for that matter?

anim = other.gameObject.GetComponent();

its at the beginning of void OnTriggerEnter(Collider other)

1 Like