ボタンを押すとイメージに付いているアニメーションの速度が10になるコードです。
うまくメソッドを呼び出せません。
ご教授お願いします。
以下コードです 画像貼り直しました
C#
1public class GameManager : MonoBehaviour 2{ 3 [SerializeField] Move _k; 4 5 public void OnButton() 6 { 7 Debug.Log("ok"); 8 _k.MoveButton(); 9 } 10}
C#
1public class Move : MonoBehaviour { 2 Animator _anim; 3 4 void Start () 5 { 6 _anim = this.GetComponent<Animator>(); 7 } 8 9 public void OnButton() 10 { 11 _anim.Play("NewAnimator", 0, 0.0f); 12 } 13}
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class CubeA : MonoBehaviour { 6 7 int acd = 0; 8 9 // Use this for initialization 10 void Start() 11 { 12 13 } 14 15 // Update is called once per frame 16 void Update() 17 { 18 if (acd == 1) 19 { 20 transform.Rotate(new Vector3(0, 90, 0) * Time.deltaTime, Space.World); 21 22 23 }else if(acd == 2){ 24 transform.position = transform.position + new Vector3(0, 5, 0); 25 } 26 27 } 28 public void CubeStrt() 29 { 30 Invoke("DelayMethodA", 1.0f); 31 } 32 33 void DelayMethodA() 34 { 35 if (acd == 0) 36 { 37 this.acd = 2; 38 Invoke("DelayMethodB", 0.1f); 39 } 40 } 41 42 void DelayMethodB() 43 { 44 this.acd = 1; 45 } 46 47}
エラー内容
NullReferenceException: Object reference not set to an instance of an object
StartButton.OnButton () (at Assets/StartButton.cs:12)
NullReferenceException:オブジェクト参照がオブジェクトのインスタンスに設定されていない
using UnityEngine; using System.Collections; public class Minor_1 : MonoBehaviour { public Transform followTfm; bool onStert = false; float smoothTime = 0.1f; Vector3 velocity = Vector3.zero; void Start() { gameObject.SetActive(true); Invoke("DelayMethod", 3.5f); } void Update() { if (onStert) { // 追従対象オブジェクトのTransformから、目的地を算出 Vector3 targetPos = followTfm.TransformPoint(new Vector3(3f, 3f, 7f)); // 移動 transform.position = Vector3.SmoothDamp(transform.position, targetPos, ref velocity, smoothTime); Invoke("DelayMethodA", 0.3f); } } void DelayMethod(){ onStert = true; } void DelayMethodA() { gameObject.SetActive(false); } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/03/06 06:42
2018/03/06 08:00