###前提・実現したいこと
初質問です。
最近unityを始めましたがプログラムの基礎もわかってないままやっています。サルでもわかるような用語でお願いします
unityで「ボタンを押すとキャラクターがアニメーションする」というプログラムを書きたいのですが、サイトで拾ったものを改造してもエラーが出てしまいます。
buttonScriptでボタンの状態、もし押されたらActionをonにし、ThirdPersonCharacterにActionを受け渡したいのですが、エラーで動かすことすらできません。
###発生している問題・エラーメッセージ
Assets/Standard Assets/Characters/ThirdPersonCharacter/Scripts/ThirdPersonCharacter.cs(70,13): error CS0246: The type or namespace name `buttonScript' could not be found. Are you missing a using directive or an assembly reference? (buttonScriptというものが何かわかっていないということでしょうか?)
###該当のソースコード
C#
1/*buttonScript.cs*/ 2 3using UnityEngine; 4using System.Collections; 5 6public class buttonScript : MonoBehaviour 7{ 8 [SerializeField] 9 public bool Action; 10 public void ButtonPush() 11 { 12 Action = true; 13 gameObject.SetActive(false); 14 Debug.Log("button pushed"); 15 } 16 17} 18 19/*ThirdPersonCharacter.cs*/ 20using UnityEngine; 21using UnityEngine.UI; 22using System.Collections; 23 24namespace UnityStandardAssets.Characters.ThirdPerson 25{ 26 [RequireComponent(typeof(Rigidbody))] 27 [RequireComponent(typeof(CapsuleCollider))] 28 [RequireComponent(typeof(Animator))] 29 public class ThirdPersonCharacter : MonoBehaviour 30 { 31 public bool ActionB; 32 GameObject eventa; 33 34 35 void Start() 36 { 37 38 eventa = GameObject.Find("button1"); 39 buttonScript ba = eventa.GetComponent<buttonScript>();//エラー発生? 40 ActionB = ba.Action 41 42 } 43 44 public void UpdateAnimator(Vector3 move) 45 { 46 m_Animator.SetBool("Action", ActionB); 47 } 48//今のところbuttonScriptについて何も書いていないupdate()関数などは省いています 49 50
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/06/22 11:19