So my issue is that even with a network animator and all of the boxes checked the animations are still not seen by other players. my script for attacking works as follows. So im wondering how can i edit my script to properly sync the animations?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class clickattack : NetworkBehaviour {
public GameObject targeting;
public GameObject sword;
public float strength;
public Animator anim;
public bool canclick;
IEnumerator attackisopen()
{
canclick = true;
GetComponent<Attackdirection>().canattack = true;
yield return new WaitForSeconds(10 * Time.deltaTime);
sword.GetComponent<Gettindamaged>().candamage = true;
yield return new WaitForSeconds(80 * Time.deltaTime);
GetComponent<Attackdirection>().canattack = false;
canclick = false;
}
void attacking()
{
if(Input.GetKeyDown(KeyCode.F) && canclick == false)
{
StartCoroutine(attackisopen());
attackanimationsuccesful();
}
}
void attackanimationsuccesful()
{
if (GetComponent<Attackdirection>().attackingleft == true)
{
anim.SetTrigger("Attackleft");
}
if (GetComponent<Attackdirection>().attackingup == true )
{
anim.SetTrigger("Attackup");
}
if (GetComponent<Attackdirection>().attackingright == true)
{
anim.SetTrigger("Attackright");
}
if (GetComponent<Attackdirection>().attackingdown == true)
{
anim.SetTrigger("Attackdown");
}
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (!isLocalPlayer)
{
return;
}
attacking();
}
}
Mark a method with Command and when you call it. A packet is sent to the server instructing it to run the method. So basically what’s in the Command method is server code. Rpc is same but flipped.
So sent from server to clients to run said code.
oh i see why now thanks for the edit. is there a way to further reduce the time between when the animation starts on your client and the other client. i noticed even edited theres still some issues with a delay between when the animations both started
ah ok makes complete sense figured id ask as i know that unity deals with some more complex concepts such as the send rate and such but if its just regular ping then ill have to deal with it some other way