通知
すべてクリア
21/07/2025 3:28 pm
Rigidbody shellInstance =
Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody;
上は、PrefabのShellのRigidbodyをInstantiateで取得するTankShooting.cs中の一文なのですが、
そのShellInstanceの親のGameObjectを取得するには、どうすればよいでしょうか?
21/07/2025 3:28 pm
GetComponentInParentで取得できます。
逆に親から子要素を取得するにはGetComponentInChildrenを使用します。詳しい情報は以下のサイトを参考してください。
https://indie-game-creation-with-unity.hatenablog.com/entry/getcomponent-in-parent