提示コードですが一枚目のモーションAは武器が横で上下に少しだけゆらゆらするモーションで二つ目は武器が縦になってクルクル自転するモーションBなのですが AからBへのモーションは武器の縦横が上手く反応するのですがBからAへのモーションの推移で縦になった武器が横になりません。これは何が原因なのでしょうか?
※キーフレームは設定しています。
スクリプトは武器にアタッチしています。
cs
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class TwinDagger : MonoBehaviour 6{ 7 public GameObject player; 8 public GameObject camera; 9 [SerializeField] float rotateSpeed = 600; 10 [SerializeField] float orbitSpeed = 2; 11 [SerializeField] float Y_distance = 0.5f; 12 [SerializeField] float distance = 2; 13 14 [SerializeField] Material material_Orbit; // 15 [SerializeField] Material material_Basic; // 16 17 18 19 20 21 22 // public GameObject camera; 23 private Animator animator; 24 private Animation animation; 25 private float time = 0; 26 // Start is called before the first frame update 27 void Start() 28 { 29 //animator = GetComponent<Animator>(); 30 animation = GetComponent<Animation>(); 31 32 animation["orbit_dagger"].speed = orbitSpeed; 33 34 35 36 37 } 38 39 40 41 42 // Update is called once per frame 43 void Update() 44 { 45 46 Orbit(); //武器軌道 47 48 49 Orbit_Animation(); //武器 切り替え 50 } 51 52 53 54 55 56 57 58 /*########################################## カメラの回転に沿って武器を回転移動 ##########################################*/ 59 private void Orbit() 60 { 61 62 63 Quaternion q = Quaternion.Euler(transform.forward); 64 Vector3 p = Vector3.Normalize(camera.transform.right) * distance; 65 66 Vector3 pDash = q * p; 67 pDash.y = Y_distance; 68 // transform.position = pDash; 69 70 } 71 72 73 74 /*########################################## 武器 切り替え ##########################################*/ 75 public void Orbit_Animation() 76 { 77 if(animation.IsPlaying("orbit_dagger") == true) 78 { 79 transform.Find("Object").GetComponent<Renderer>().material = material_Orbit; 80 81 time += Time.deltaTime; 82 transform.RotateAround(player.transform.position, Vector3.up, orbitSpeed * Time.deltaTime); 83 84 if(time > 1) 85 { 86 transform.Find("Object").GetComponent<Renderer>().material = material_Basic; 87 88 time = 0; 89 //animation.Stop(); 90 animation.Play("idle_dagger"); 91 } 92 } 93 94 95 96 } 97} 98 99

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2022/03/18 07:17
2022/03/18 07:34
退会済みユーザー
2022/03/18 07:35