Fix ability usage animation on remotes
This commit is contained in:
parent
494330fa1f
commit
655472a16a
@ -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
|
||||
|
@ -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<Animator>();
|
||||
agent = GetComponentInParent<NavMeshAgent>();
|
||||
photonView = GetComponentInParent<PhotonView>();
|
||||
parentController = GetComponentInParent<CharacterAnimatorParent>();
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
|
28
Assets/Scripts/CharacterAnimatorParent.cs
Normal file
28
Assets/Scripts/CharacterAnimatorParent.cs
Normal file
@ -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<PhotonView>();
|
||||
animatorController = GetComponentInChildren<CharacterAnimatorController>();
|
||||
}
|
||||
|
||||
|
||||
public void SetRemoteTriggerBasedOnAbility(int animationType)
|
||||
{
|
||||
photonView.RPC(nameof(RPC_SetTriggerBasedOnAbility), RpcTarget.Others, animationType);
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
private void RPC_SetTriggerBasedOnAbility(int animationType)
|
||||
{
|
||||
animatorController.SetTriggerBasedOnAbility((AbilityAnimationType)animationType);
|
||||
}
|
||||
}
|
11
Assets/Scripts/CharacterAnimatorParent.cs.meta
Normal file
11
Assets/Scripts/CharacterAnimatorParent.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15740b3357d70f34d8e5e53ca9c27cb0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
x
Reference in New Issue
Block a user