diff --git a/Assets/Resources/PlayerPrefab.prefab b/Assets/Resources/PlayerPrefab.prefab index da6cf895..e34ec942 100644 --- a/Assets/Resources/PlayerPrefab.prefab +++ b/Assets/Resources/PlayerPrefab.prefab @@ -156,6 +156,7 @@ GameObject: - component: {fileID: 8273564744905798527} - component: {fileID: 4996700579829439174} - component: {fileID: 9115515025738910048} + - component: {fileID: 4217372937522934288} m_Layer: 0 m_Name: PlayerPrefab m_TagString: Untagged @@ -434,6 +435,18 @@ MonoBehaviour: m_PersistentCalls: m_Calls: [] photonView: {fileID: 0} +--- !u!114 &4217372937522934288 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 480331571121010796} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 15740b3357d70f34d8e5e53ca9c27cb0, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &647488901503982106 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/CharacterAnimatorController.cs b/Assets/Scripts/CharacterAnimatorController.cs index be019aa6..4f4523a7 100644 --- a/Assets/Scripts/CharacterAnimatorController.cs +++ b/Assets/Scripts/CharacterAnimatorController.cs @@ -9,6 +9,7 @@ public class CharacterAnimatorController : MonoBehaviour Animator anim; NavMeshAgent agent; PhotonView photonView; + CharacterAnimatorParent parentController; bool isCasting; @@ -17,6 +18,7 @@ public class CharacterAnimatorController : MonoBehaviour anim = GetComponent(); agent = GetComponentInParent(); photonView = GetComponentInParent(); + parentController = GetComponentInParent(); } // Start is called before the first frame update @@ -24,7 +26,6 @@ public class CharacterAnimatorController : MonoBehaviour { if (!photonView.IsMine) { - this.enabled = false; return; } CastBarHandler.Instance.OnCastingStateChanged.AddListener(UpdateIsCastingState); @@ -33,6 +34,8 @@ public class CharacterAnimatorController : MonoBehaviour // Update is called once per frame void Update() { + if (!photonView.IsMine) return; + anim.SetFloat("movementSpeed", agent.velocity.magnitude); } @@ -43,10 +46,11 @@ public class CharacterAnimatorController : MonoBehaviour { anim.SetFloat("throwingTime", (1 / CastBarHandler.Instance.currentCastTime)); SetTriggerBasedOnAbility(CastBarHandler.Instance.currentAbility.animationType); + parentController.SetRemoteTriggerBasedOnAbility((int)CastBarHandler.Instance.currentAbility.animationType); } } - private void SetTriggerBasedOnAbility(AbilityAnimationType animationType) + public void SetTriggerBasedOnAbility(AbilityAnimationType animationType) { switch (animationType) { diff --git a/Assets/Scripts/CharacterAnimatorParent.cs b/Assets/Scripts/CharacterAnimatorParent.cs new file mode 100644 index 00000000..a32fb17f --- /dev/null +++ b/Assets/Scripts/CharacterAnimatorParent.cs @@ -0,0 +1,28 @@ +using Photon.Pun; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CharacterAnimatorParent : MonoBehaviour +{ + PhotonView photonView; + CharacterAnimatorController animatorController; + + private void Awake() + { + photonView = GetComponent(); + animatorController = GetComponentInChildren(); + } + + + public void SetRemoteTriggerBasedOnAbility(int animationType) + { + photonView.RPC(nameof(RPC_SetTriggerBasedOnAbility), RpcTarget.Others, animationType); + } + + [PunRPC] + private void RPC_SetTriggerBasedOnAbility(int animationType) + { + animatorController.SetTriggerBasedOnAbility((AbilityAnimationType)animationType); + } +} diff --git a/Assets/Scripts/CharacterAnimatorParent.cs.meta b/Assets/Scripts/CharacterAnimatorParent.cs.meta new file mode 100644 index 00000000..b5fb1df9 --- /dev/null +++ b/Assets/Scripts/CharacterAnimatorParent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 15740b3357d70f34d8e5e53ca9c27cb0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: