提示コードですが以下のコードの切り替えアニメーション終了 イベント
コメント部のコードが呼ばれたり呼ばれなかったりという現状の原因が知りたいです。十字キーを押すと武器が回転して終わったらつまり最後のフレームでアニメーションイベント呼び出しています。
cs
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class EquipManager : MonoBehaviour 6{ 7 8 /*入力*/ 9 enum Type 10 { 11 Up, 12 Down, 13 Left, 14 Right 15 } 16 17 Animator animator; 18 19 [SerializeField] GameObject orbit; 20 21 [SerializeField] GameObject cross_Up; 22 [SerializeField] GameObject cross_Left; 23 [SerializeField] GameObject cross_Right; 24 [SerializeField] GameObject cross_Down; 25 26 private bool isPush; 27 private Type crossInput; 28 29 Transform now; 30 31 //オブジェクトプール 32 Transform[] crossUp_Pool; 33 Transform[] crossLeft_Pool; 34 Transform[] crossRight_Pool; 35 36 37 void Start() 38 { 39 animator = GetComponent<Animator>(); 40 animator.enabled = false; 41 42 isPush = false; 43 orbit.SetActive(false); 44 45 crossUp_Pool = GetObjectPool(cross_Up); 46 crossLeft_Pool = GetObjectPool(cross_Left); 47 crossRight_Pool = GetObjectPool(cross_Right); 48 49 crossInput = Type.Up; 50 51 now = GetInstance(crossInput); 52 53 } 54 55 void Update() 56 { 57 58 if ((Input.GetAxis("Cross_Horizontal") == 1) && (isPush == false)) 59 { 60 Orbit(); 61 crossInput = Type.Right; 62 } 63 else if ((Input.GetAxis("Cross_Horizontal") == -1) && (isPush == false)) 64 { 65 Orbit(); 66 crossInput = Type.Left; 67 } 68 else if ((Input.GetAxis("Cross_Vertical") == -1) && (isPush == false)) 69 { 70 Orbit(); 71 crossInput = Type.Down; 72 } 73 else if ((Input.GetAxis("Cross_Vertical") == 1) && (isPush == false)) 74 { 75 Orbit(); 76 crossInput = Type.Up; 77 } 78 79 if (Input.GetButtonDown("R1") == true) 80 { 81 82 } 83 84 Rotate(); 85 } 86 87 /*############################ オブジェクトプールを設定 ############################*/ 88 private Transform[] GetObjectPool(GameObject game) 89 { 90 Transform[] pool = new Transform[game.transform.childCount]; 91 92 for (int i = 0; i < pool.Length; i++) 93 { 94 pool[i] = game.transform.GetChild(i); 95 } 96 97 return pool; 98 } 99 100 101 /*############################ オブジェクトを返す ############################*/ 102 private Transform GetInstance(Type type) 103 { 104 105 if (type == Type.Right) 106 { 107 foreach(Transform t in crossRight_Pool) 108 { 109 if(t.gameObject.activeSelf == false) 110 { 111 t.gameObject.SetActive(true); 112 113 return t; 114 } 115 } 116 117 return Instantiate(crossRight_Pool[0], cross_Right.transform); 118 } 119 else if (type == Type.Left) 120 { 121 foreach (Transform t in crossLeft_Pool) 122 { 123 if (t.gameObject.activeSelf == false) 124 { 125 t.gameObject.SetActive(true); 126 127 return t; 128 } 129 } 130 131 return Instantiate(crossLeft_Pool[0], cross_Left.transform); 132 } 133 else if (type == Type.Down) 134 { 135 136 } 137 else if (type == Type.Up) 138 { 139 foreach (Transform t in crossUp_Pool) 140 { 141 if (t.gameObject.activeSelf == false) 142 { 143 t.gameObject.SetActive(true); 144 145 return t; 146 } 147 } 148 149 return Instantiate(crossUp_Pool[0], cross_Up.transform); 150 } 151 152 return null; 153 } 154 155 /*############################ 回転 ############################*/ 156 private void Rotate() 157 { 158 Vector3 vec = transform.forward; 159 vec.y = 0; 160 float f = 0; 161 162 f = Vector3.SignedAngle(vec, Camera.main.transform.forward, Vector3.up); 163 164 transform.rotation = Quaternion.LookRotation(Vector3.Scale(Camera.main.transform.forward, new Vector3(1, 0, 1)), transform.up); 165 } 166 167 168 169 /*############################ オブジェクト 参照 ############################*/ 170 private void Instannce() 171 { 172 if (crossInput == Type.Right) 173 { 174 175 } 176 else if (crossInput == Type.Left) 177 { 178 179 } 180 else if (crossInput == Type.Down) 181 { 182 183 } 184 else if (crossInput == Type.Up) 185 { 186 187 } 188 189 } 190 191 192 /*############################ 切り替えアニメーション ############################*/ 193 private void Orbit() 194 { 195 isPush = true; 196 orbit.SetActive(true); 197 animator.enabled = true; 198 199 animator.SetTrigger("Orbit"); 200 } 201 202 203 204 /*############################ 切り替えアニメーション終了 イベント ############################*/ 205 public void OrbitEnd_Event() 206 { 207 Debug.Log("あああ"); 208 animator.enabled = false; 209 210 orbit.SetActive(false); 211 212 isPush = false; 213 214 215 now = GetInstance(crossInput); 216 } 217 218 219} 220

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。