実現したいこと
error CS0246: The type or namespace name `________' Could not be found.
Are you missing a using directive of assembly reference?と出てくるのを解決したいです。
発生している問題・分からないこと
error CS0246: The type or namespace name InputSystem_Actions' Could not be found. Are you missing a using directive of assembly reference? error CS0246: The type or namespace name
GameManagerScript' Could not be found.
Are you missing a using directive of assembly reference?の二つが出てきます。
エラーメッセージ
error
1error CS0246: The type or namespace name `InputSystem_Actions' Could not be found. 2Are you missing a using directive of assembly reference? 3error CS0246: The type or namespace name `GameManagerScript' Could not be found. 4Are you missing a using directive of assembly reference?
該当のソースコード
C++
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.InputSystem; 5 6public class PlayerController : MonoBehaviour 7{ 8 // 移動する方向のVector2 9 public Vector2 MoveVector; 10 11 //プレイヤーが動くかどうかのbool型変数 12 public bool IsMove; 13 14 //スティックの倒し具合に応じたスピードの数値 15 public float Speed; 16 17 //カメラが移動する方向のVector2 18 public Vector2 CameraMoveVector; 19 20 //カメラが動くかどうかのbool型変数 21 public bool IsCameraMove; 22 23 //PlayerPositionObjectの略 24 GameObject PlayerPos; 25 Animator anim; 26 Rigidbody Rbody; 27 28 //InputDSystemを変数として定義 29 InputSystem_Actions ISA; 30 public float JumpPower; 31 32 //ゲームマネージャー 33 public GameObject GameManager; 34 35 //ゲームマネージャーのコントローラー 36 public GameManagerScript GameManagerController; 37 38 //メンバ変数に追加 39 private float targetSpeed = 0f; 40 public AudioSource JumpAudio; 41 public AudioSource FootStepAudio; 42 public bool isGrounded = true; 43 private bool wasGrounded = true; //前フレームの地面状態 44 45 // Start is called before the first frame update 46 void Start() 47 { 48 //PlayerPositionObjectのを探す 49 PlayerPos = GameObject.Find("PlayerPositionObject"); 50 51 //アニメーターコンポーネントを取得 52 anim = GetComponent<Animator>(); 53 54 //Rigidbodyコンポーネントを取得 55 Rbody = GetComponent<Rigidbody>(); 56 57 //Input Systemのアクションマップ(ISA)を初期化(新しく作る) 58 ISA = new InputSystem_Actions(); 59 60 //入力を有効化(これをしないと操作が反応しない) 61 ISA.Enable(); 62 63 //ゲームマネージャーのGameManagerScriptを取得 64 GameManagerController = GameManager.GetComponent<GameManagerScript>(); 65 JumpAudio.volume = 0.3f; 66 } 67 68 // Update is called once per frame 69 void Update() 70 { 71 float smoothing = 10f; //スピード変化の滑らかさ(大きいほど素早く反映) 72 //現在のSpeedを、目標値に向かって徐々に近づける 73 Speed = Mathf.Lerp(Speed, targetSpeed, Time.deltaTime * smoothing); 74 75 //ごくわずかな差ならぴたっとスナップして振動を防ぐ 76 if (Mathf.Abs(Speed - targetSpeed) < 0.01f) 77 { 78 Speed = targetSpeed; 79 } 80 anim.SetFloat("VelocityY", Rbody.linearVelocity.y); 81 82 //キャラのすぐ下に光線を飛ばして地面に足がついているか判定 83 if (isGround) 84 { 85 //ジャンプ力がたまらないようにジャンプ前にRigidbodyの力をすべてゼロにする 86 Rbody.linearVelocity = Vector3.zero; 87 88 //上方向にddForceする 89 Rbody.AddForce(Vector3.up * JumpPower); 90 91 //前方向にddForceする 92 Rbody.AddForce(transform.forward * Speed * 800); 93 94 //ジャンプの音を再生 95 JumpAudio.Play(); 96 } 97 //アニメーションのジャンプパラメーターをファルスに 98 anim.SetBool("IsJump", false); 99 100 //もしプレイヤーが動くかどうかのbool型変数がtrueなら 101 if (IsMove && GameManagerController.IsMenu == false) 102 { 103 //プレイヤーの前方向にスピードを掛ける 104 if (Physics. Raycast (new Vector3(transform. position. x, transform. position. y + 1, 105 transform. position. z), transform. forward, 2) == false) 106 { 107 transform. position += transform. forward * Speed * 15 * Time. deltaTime; 108 } 109 //回転スピード(調整可能) 110 float rotationSpeed = 10f; 111 //入力方向を角度に変換 112 float targetYRotation = Mathf. Atan2 (MoveVector. x, MoveVector. y) 113 * Mathf. Rad2Deg + PlayerPos. transform. rotation. eulerAngles. y; 114 //目標の回転 115 Quaternion targetRotation = Quaternion. Euler(0, targetYRotation, 0) ; 116 //補間して回転(なめらかに) 117 transform. rotation = Quaternion. Lerp(transform. rotation, 118 targetRotation, rotationSpeed * Time. deltaTime) ; 119 //動くアニメーションパラメーター設定 120 anim. SetBool ("IsMove", true) ; 121 //アニメーション遷移速度を設定 122 anim. SetFloat ("MoveSpeed", Speed) ; 123 //足音のピッチを歩く、走る速度に合わせる 124 FootStepsAudio. pitch = Speed * 2 + 0.2f; 125 if (!FootStepsAudio. isPlaying) 126 { 127 //足音を再生 128 FootStepsAudio. Play (); 129 } 130 } 131 else 132 { 133 //アニメーションのジャンプパラメーターをトゥルーに 134 anim.SetBool("IsJump", true); 135 } 136 if (!isGrounded) 137 { 138 //足音を止める 139 FootStepsAudio.Stop(); 140 } 141 } 142 143 void FixedUpdate() 144 { 145 //地面チェック(簡易) 146 wasGrounded = isGrounded; 147 if (Mathf. Abs (Rbody. linearVelocity. y) < 30 && 148 Physics. Raycast (new Vector3(transform. position. x, transform. position. y + 1, 149 transform. position. z), Vector3. down, 2)) 150 { 151 isGrounded = true; 152 } 153 if (Mathf. Abs (Rbody. IinearVelocity. y) > 30) 154 { 155 isGrounded = false; 156 } 157 158 //着地検出:前フレームでは空中、今は地面に接触 159 if (!wasGrounded && isGrounded) 160 { 161 //ジャンプの音(着地にも同じ音を使用)を再生 162 JumpAudio. Play () ; 163 } 164 } 165 166 //プレイヤーが動くための入力(十字キー、WASDキー、左スティック)が押されたときの 167 //入力の方向を取得する関数 168 169 public void OnMove (InputAction. CallbackContext Context) 170 { 171 //入力された移動方向ベクトルを取得 172 MoveVector = Context. ReadValue<Vector2>(); 173 //入力が少しでもあれば移動状態にする 174 IsMove = Mathf. Abs (MoveVector. x) > 0.1f || Mathf. Abs (MoveVector. y) > 0.1f; 175 //入力の強さ(スティックの倒し具合) 176 float rawSpeed = MoveVector.magnitude; 177 // Proコンの最大スティック倒し量に合わせて補正 178 float maxStickValue = 0.7f; 179 //補正して0~1の範囲に正規化 180 targetSpeed = Mathf.Clamp01(rawSpeed / maxStickValue); 181 //ほぼ最大入力なら強制的に1にスナップして安定化 182 if (targetSpeed >= 0.92f) 183 { 184 targetSpeed = 1f; 185 } 186 } 187 //カメラが動くための入力(マウス、右スティック)が押された時の 188 //入力の方向を取得する関数 189 public void CameraMove(InputAction.CallbackContext Context) 190 { 191 //入力された動く方向のVector 192 CameraMoveVector = Context.ReadValue<Vector2>(); 193 //少しでもスティックが動いたらプレイヤーが動くかどうかのbool型変数をtrueにする 194 IsCameraMove = Mathf.Abs(Context.ReadValue<Vector2>().x) > 0.1 195 || Mathf.Abs(Context.ReadValue<Vector2>().y) > 0.1; 196 } 197} 198
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
解決方法がよくわからなかった
補足
特になし
