提示コードですがCollision
オブジェクトにアタッチしているのが下記のスクリプトです。Enemy
と当たったらweapon
オブジェクト(提示子画像のObject)が消えてHit_Effect
オブジェクトでパーティクルが再生されるのですがなぜかObject
をSetActive(false);
にするとパーティクルも消えてしまいます。これはなぜでしょうか?
cs
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class Weapon_Collision : MonoBehaviour 6{ 7 [SerializeField] GameObject weapon; 8 [SerializeField] GameObject hitEffect; 9 10 // Start is called before the first frame update 11 void Start() 12 { 13 14 } 15 16 // Update is called once per frame 17 void Update() 18 { 19 20 } 21 22 public void OnTriggerEnter(Collider other) 23 { 24 if(other.gameObject.tag == "Enemy") 25 { 26 weapon.SetActive(false); 27 28 hitEffect.GetComponent<ParticleSystem>().Play(); 29 } 30 } 31} 32
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2022/03/29 03:16
2022/03/29 03:24
退会済みユーザー
2022/03/29 03:29
2022/03/29 03:43
退会済みユーザー
2022/03/29 03:57