前提・実現したいこと
初質問です。
Unityにて、Standard AssetsのThird Person Characterを用いてUnityちゃんを動かしています。
Unityちゃんの操作中にqキーを押したらThird Person User Controlのスクリプトを無効にしてUnityちゃんが動かないようにして、再びqキーを押すと操作できるようになる、という風に操作できるかできないかをキー入力で変更できる機能を追加したいと思っているのですが、エラーが出てうまくいきません。
発生している問題・エラーメッセージ
Assets\StopChan.cs(11,22): error CS0246: The type or namespace name 'ThirdPersonUserControl' could not be found (are you missing a using directive or an assembly reference?) Assets\StopChan.cs(21,30): error CS0246: The type or namespace name 'ThirdPersonUserControl' could not be found (are you missing a using directive or an assembly reference?) Assets\StopChan.cs(26,30): error CS0246: The type or namespace name 'ThirdPersonUserControl' could not be found (are you missing a using directive or an assembly reference?)
該当のソースコード
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class StopChan : MonoBehaviour 6{ 7 bool UniChanger = true; 8 9 void Start() 10 { 11 GetComponent<ThirdPersonUserControl>().enabled = true; 12 } 13 14 // Update is called once per frame 15 void Update() 16 { 17 if (Input.GetKeyDown("q")) 18 { 19 if (UniChanger == true) 20 { 21 GetComponent<ThirdPersonUserControl>().enabled = false; 22 UniChanger = false; 23 } 24 else 25 { 26 GetComponent<ThirdPersonUserControl>().enabled = true; 27 UniChanger = true; 28 } 29 } 30 31 32 33 } 34}
試したこと
上記とほとんど同じスクリプトで別の物体で有効化無効化の切り替えを試してみたらうまくいったので、ThirdPersonUserControlの読み込みがうまくいっていないのではないかと思います。
また、上記のスクリプトを追加する前はUnityちゃんは問題なく動いています。
別のスクリプトでUnityちゃんを動かしたらいけるのかもしれませんが、ThirdPersonCharactorを使いたいです。
どうすれば良いでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/10 20:45