teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

14

誤字

2018/03/13 06:07

投稿

harunasan
harunasan

スコア125

title CHANGED
File without changes
body CHANGED
@@ -131,4 +131,5 @@
131
131
  gameObject.SetActive(false);
132
132
  }
133
133
  }
134
- ```
134
+ ```
135
+ [GOd内容](https://www.youtube.com/watch?v=hFyANXapLIk)

13

コードの追加

2018/03/13 06:07

投稿

harunasan
harunasan

スコア125

title CHANGED
File without changes
body CHANGED
@@ -88,4 +88,47 @@
88
88
 
89
89
 
90
90
 
91
- [リンク内容](http://tech.pjin.jp/blog/2016/12/14/unity_minor_1/)
91
+ [リンク内容](http://tech.pjin.jp/blog/2016/12/14/unity_minor_1/)
92
+ ```ここに言語を入力
93
+ using UnityEngine;
94
+ using System.Collections;
95
+
96
+ public class Minor_1 : MonoBehaviour
97
+ {
98
+
99
+ public Transform followTfm;
100
+
101
+ bool onStert = false;
102
+
103
+ float smoothTime = 0.1f;
104
+
105
+ Vector3 velocity = Vector3.zero;
106
+
107
+ void Start()
108
+ {
109
+ gameObject.SetActive(true);
110
+ Invoke("DelayMethod", 3.5f);
111
+ }
112
+
113
+ void Update()
114
+ {
115
+ if (onStert)
116
+ {
117
+ // 追従対象オブジェクトのTransformから、目的地を算出
118
+ Vector3 targetPos = followTfm.TransformPoint(new Vector3(3f, 3f, 7f));
119
+
120
+ // 移動
121
+ transform.position =
122
+ Vector3.SmoothDamp(transform.position, targetPos, ref velocity, smoothTime);
123
+ Invoke("DelayMethodA", 0.3f);
124
+ }
125
+ }
126
+ void DelayMethod(){
127
+ onStert = true;
128
+ }
129
+ void DelayMethodA()
130
+ {
131
+ gameObject.SetActive(false);
132
+ }
133
+ }
134
+ ```

12

url

2018/03/13 06:00

投稿

harunasan
harunasan

スコア125

title CHANGED
File without changes
body CHANGED
@@ -87,4 +87,5 @@
87
87
  NullReferenceException:オブジェクト参照がオブジェクトのインスタンスに設定されていない
88
88
 
89
89
 
90
+
90
- http://tech.pjin.jp/blog/2016/12/14/unity_minor_1/
91
+ [リンク内容](http://tech.pjin.jp/blog/2016/12/14/unity_minor_1/)

11

url追加

2018/03/13 03:09

投稿

harunasan
harunasan

スコア125

title CHANGED
File without changes
body CHANGED
@@ -84,4 +84,7 @@
84
84
  NullReferenceException: Object reference not set to an instance of an object
85
85
  StartButton.OnButton () (at Assets/StartButton.cs:12)
86
86
 
87
- NullReferenceException:オブジェクト参照がオブジェクトのインスタンスに設定されていない
87
+ NullReferenceException:オブジェクト参照がオブジェクトのインスタンスに設定されていない
88
+
89
+
90
+ http://tech.pjin.jp/blog/2016/12/14/unity_minor_1/

10

追記

2018/03/13 03:07

投稿

harunasan
harunasan

スコア125

title CHANGED
File without changes
body CHANGED
@@ -55,20 +55,25 @@
55
55
 
56
56
 
57
57
  }else if(acd == 2){
58
- transform.position = transform.position + new Vector3(0, 10, 0);
58
+ transform.position = transform.position + new Vector3(0, 5, 0);
59
59
  }
60
60
 
61
61
  }
62
-
63
62
  public void CubeStrt()
64
63
  {
64
+ Invoke("DelayMethodA", 1.0f);
65
+ }
66
+
67
+ void DelayMethodA()
68
+ {
65
69
  if (acd == 0)
66
70
  {
67
71
  this.acd = 2;
68
- Invoke("DelayMethod", 0.01f);
72
+ Invoke("DelayMethodB", 0.1f);
69
73
  }
70
74
  }
75
+
71
- void DelayMethod()
76
+ void DelayMethodB()
72
77
  {
73
78
  this.acd = 1;
74
79
  }

9

追記

2018/03/07 13:16

投稿

harunasan
harunasan

スコア125

title CHANGED
File without changes
body CHANGED
@@ -31,6 +31,50 @@
31
31
  }
32
32
  }
33
33
  ```
34
+ ```C#
35
+ using System.Collections;
36
+ using System.Collections.Generic;
37
+ using UnityEngine;
38
+
39
+ public class CubeA : MonoBehaviour {
40
+
41
+ int acd = 0;
42
+
43
+ // Use this for initialization
44
+ void Start()
45
+ {
46
+
47
+ }
48
+
49
+ // Update is called once per frame
50
+ void Update()
51
+ {
52
+ if (acd == 1)
53
+ {
54
+ transform.Rotate(new Vector3(0, 90, 0) * Time.deltaTime, Space.World);
55
+
56
+
57
+ }else if(acd == 2){
58
+ transform.position = transform.position + new Vector3(0, 10, 0);
59
+ }
60
+
61
+ }
62
+
63
+ public void CubeStrt()
64
+ {
65
+ if (acd == 0)
66
+ {
67
+ this.acd = 2;
68
+ Invoke("DelayMethod", 0.01f);
69
+ }
70
+ }
71
+ void DelayMethod()
72
+ {
73
+ this.acd = 1;
74
+ }
75
+
76
+ }
77
+ ```
34
78
  エラー内容
35
79
  NullReferenceException: Object reference not set to an instance of an object
36
80
  StartButton.OnButton () (at Assets/StartButton.cs:12)

8

脱字

2018/03/07 13:08

投稿

harunasan
harunasan

スコア125

title CHANGED
File without changes
body CHANGED
@@ -18,15 +18,16 @@
18
18
  ```
19
19
  ```C#
20
20
  public class Move : MonoBehaviour {
21
+ Animator _anim;
21
22
 
22
23
  void Start ()
23
24
  {
24
- this.GetComponent<Animator>().speed = 0;
25
+ _anim = this.GetComponent<Animator>();
25
26
  }
26
-
27
+
27
- public void MoveButton()
28
+ public void OnButton()
28
29
  {
29
- this.GetComponent<Animator>().speed = 10;
30
+ _anim.Play("NewAnimator", 0, 0.0f);
30
31
  }
31
32
  }
32
33
  ```

7

画像の追加

2018/03/06 08:01

投稿

harunasan
harunasan

スコア125

title CHANGED
File without changes
body CHANGED
@@ -1,9 +1,9 @@
1
1
  ボタンを押すとイメージに付いているアニメーションの速度が10になるコードです。
2
2
  うまくメソッドを呼び出せません。
3
3
  ご教授お願いします。
4
- 以下コードです
4
+ 以下コードです **画像貼り直しました**
5
+ ![イメージ説明](9b597a845edae688e4408f15edc01bf8.png)
5
- ![イメージ説明](17ea588eab47739ab275fa952616691e.png)
6
+ ![イメージ説明](21714ad2f3b58bd52e0e08d5533eaa24.png)
6
-
7
7
  ```C#
8
8
  public class GameManager : MonoBehaviour
9
9
  {

6

誤字

2018/03/06 06:42

投稿

harunasan
harunasan

スコア125

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,5 @@
1
1
  ボタンを押すとイメージに付いているアニメーションの速度が10になるコードです。
2
- なぜthis.でエラーするのでしょ
2
+ まくメソッドを呼び出せません
3
3
  ご教授お願いします。
4
4
  以下コードです
5
5
  ![イメージ説明](17ea588eab47739ab275fa952616691e.png)

5

不要な行の修正

2018/03/06 05:10

投稿

harunasan
harunasan

スコア125

title CHANGED
@@ -1,1 +1,1 @@
1
- this.でゲムオブジェクト取得できない
1
+ ボタンを押したらアニメション動かす
body CHANGED
@@ -3,33 +3,7 @@
3
3
  ご教授お願いします。
4
4
  以下コードです
5
5
  ![イメージ説明](17ea588eab47739ab275fa952616691e.png)
6
- ```C#
7
- 〜省略〜
8
- public class NewBehaviourScript1 : MonoBehaviour {
9
-
10
- public void OnButton()
11
- {
12
- NewBehaviourScript.StretButton();
13
- }
14
- }
15
- ```
16
- ```C#
17
- 〜省略〜
18
- public class NewBehaviourScript : MonoBehaviour {
19
6
 
20
- void Start () {
21
- this.GetComponent<Animator>().speed = 0;
22
- }
23
-
24
- public static void StretButton()
25
- {
26
- this.GetComponent<Animator>().speed = 10;
27
- }
28
-
29
- }
30
-
31
- ```
32
- ソース修正しました 一応this.エラーは消えました。
33
7
  ```C#
34
8
  public class GameManager : MonoBehaviour
35
9
  {

4

リネーム

2018/03/06 05:10

投稿

harunasan
harunasan

スコア125

title CHANGED
File without changes
body CHANGED
@@ -31,7 +31,7 @@
31
31
  ```
32
32
  ソース修正しました 一応this.エラーは消えました。
33
33
  ```C#
34
- public class StartButton : MonoBehaviour
34
+ public class GameManager : MonoBehaviour
35
35
  {
36
36
  [SerializeField] Move _k;
37
37
 

3

追記2

2018/03/06 04:57

投稿

harunasan
harunasan

スコア125

title CHANGED
File without changes
body CHANGED
@@ -31,27 +31,33 @@
31
31
  ```
32
32
  ソース修正しました 一応this.エラーは消えました。
33
33
  ```C#
34
- public class NewBehaviourScript1 : MonoBehaviour {
34
+ public class StartButton : MonoBehaviour
35
+ {
35
- [SerializeField] NewBehaviourScript _k;
36
+ [SerializeField] Move _k;
36
37
 
37
38
  public void OnButton()
38
39
  {
40
+ Debug.Log("ok");
39
- _k.StretButton();
41
+ _k.MoveButton();
40
42
  }
41
43
  }
42
44
  ```
43
45
  ```C#
44
- public class NewBehaviourScript : MonoBehaviour {
46
+ public class Move : MonoBehaviour {
45
47
 
46
48
  void Start ()
47
49
  {
48
50
  this.GetComponent<Animator>().speed = 0;
49
51
  }
50
52
 
51
- public void StretButton()
53
+ public void MoveButton()
52
54
  {
53
55
  this.GetComponent<Animator>().speed = 10;
54
56
  }
57
+ }
58
+ ```
59
+ エラー内容
60
+ NullReferenceException: Object reference not set to an instance of an object
61
+ StartButton.OnButton () (at Assets/StartButton.cs:12)
55
62
 
56
- }
57
- ```
63
+ NullReferenceException:オブジェクト参照がオブジェクトのインスタンスに設定されていない

2

追記

2018/03/06 04:49

投稿

harunasan
harunasan

スコア125

title CHANGED
File without changes
body CHANGED
@@ -28,4 +28,30 @@
28
28
 
29
29
  }
30
30
 
31
+ ```
32
+ ソース修正しました 一応this.エラーは消えました。
33
+ ```C#
34
+ public class NewBehaviourScript1 : MonoBehaviour {
35
+ [SerializeField] NewBehaviourScript _k;
36
+
37
+ public void OnButton()
38
+ {
39
+ _k.StretButton();
40
+ }
41
+ }
42
+ ```
43
+ ```C#
44
+ public class NewBehaviourScript : MonoBehaviour {
45
+
46
+ void Start ()
47
+ {
48
+ this.GetComponent<Animator>().speed = 0;
49
+ }
50
+
51
+ public void StretButton()
52
+ {
53
+ this.GetComponent<Animator>().speed = 10;
54
+ }
55
+
56
+ }
31
57
  ```

1

不要な行省略

2018/03/06 04:29

投稿

harunasan
harunasan

スコア125

title CHANGED
File without changes
body CHANGED
@@ -4,10 +4,7 @@
4
4
  以下コードです
5
5
  ![イメージ説明](17ea588eab47739ab275fa952616691e.png)
6
6
  ```C#
7
- using System.Collections;
8
- using System.Collections.Generic;
9
- using UnityEngine;
7
+ 〜省略〜
10
-
11
8
  public class NewBehaviourScript1 : MonoBehaviour {
12
9
 
13
10
  public void OnButton()
@@ -17,10 +14,7 @@
17
14
  }
18
15
  ```
19
16
  ```C#
20
- using System.Collections;
21
- using System.Collections.Generic;
22
- using UnityEngine;
17
+ 〜省略〜
23
-
24
18
  public class NewBehaviourScript : MonoBehaviour {
25
19
 
26
20
  void Start () {