質問編集履歴
1
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,3 +7,237 @@
|
|
7
7
|
具体的にいうと、このオブジェクトのグラフィックは Spriterendererを動的に変更することとAnimationのふた通りで変えているのですが、前者がうまくいきません。おそらく、その理由はアニメーションが常時発動して邪魔をしているためと思われますが、Animationspeedを0にしても、Animationが優先されてしまい、またAnimationのExitを使用しても再びAnimationがEntryから始まってしまうので、常時アニメーションで上書きされてしまいます。
|
8
8
|
|
9
9
|
どうすればいいですか?
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
```
|
14
|
+
|
15
|
+
using System.Collections;
|
16
|
+
|
17
|
+
using System.Collections.Generic;
|
18
|
+
|
19
|
+
using UnityEngine;
|
20
|
+
|
21
|
+
using UnityEngine.SceneManagement;
|
22
|
+
|
23
|
+
public class PlayerS : MonoBehaviour
|
24
|
+
|
25
|
+
{
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
SpriteRenderer SPRE;
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
public Sprite PDOWN;
|
34
|
+
|
35
|
+
public Sprite PRIGHT;
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
public Sprite PUP;
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
public int[] EventsS = new int[10] { 0, 0, 0, 0, 0, 00, 0, 0, 00, 0, };
|
44
|
+
|
45
|
+
AudioSource[] sounds;
|
46
|
+
|
47
|
+
Animator animator;
|
48
|
+
|
49
|
+
MapManager MMS;
|
50
|
+
|
51
|
+
public GameObject MapManagerR;
|
52
|
+
|
53
|
+
public GameObject Gary;
|
54
|
+
|
55
|
+
Doctor GaryS;
|
56
|
+
|
57
|
+
public int FieldNUM;
|
58
|
+
|
59
|
+
public bool EnCount;
|
60
|
+
|
61
|
+
public bool BattleS;
|
62
|
+
|
63
|
+
public bool S;//歩けるか
|
64
|
+
|
65
|
+
public GameObject Chat;
|
66
|
+
|
67
|
+
string T;
|
68
|
+
|
69
|
+
string C;
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
bool AS = false;
|
74
|
+
|
75
|
+
public float movespeed;
|
76
|
+
|
77
|
+
// Start is called before the first frame update
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
void Start()
|
84
|
+
|
85
|
+
{
|
86
|
+
|
87
|
+
SPRE = gameObject.GetComponent<SpriteRenderer>();
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
SPRE.sprite = PDOWN;
|
92
|
+
|
93
|
+
Debug.Log(SPRE.sprite);
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
GaryS = Gary.GetComponent<Doctor>();
|
98
|
+
|
99
|
+
EventsS = new int[] { 0, 0, 0 };
|
100
|
+
|
101
|
+
this.animator = GetComponent<Animator>();
|
102
|
+
|
103
|
+
MMS = MapManagerR.GetComponent<MapManager>();
|
104
|
+
|
105
|
+
transform.position = new Vector2(-26.5f, 41);
|
106
|
+
|
107
|
+
sounds = GetComponents<AudioSource>();
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
if (EventsS[0] == 1)
|
112
|
+
|
113
|
+
{
|
114
|
+
|
115
|
+
Gary.SetActive(false);
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
else
|
120
|
+
|
121
|
+
{
|
122
|
+
|
123
|
+
GaryS.Down();
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
void FixedUpdate()
|
134
|
+
|
135
|
+
//void Update()
|
136
|
+
|
137
|
+
{
|
138
|
+
|
139
|
+
//if (Input.GetKeyDown(KeyCode.R))
|
140
|
+
|
141
|
+
//{
|
142
|
+
|
143
|
+
// //transform.position = new Vector2(320, -77);
|
144
|
+
|
145
|
+
// EnCount = true;
|
146
|
+
|
147
|
+
//}
|
148
|
+
|
149
|
+
transform.rotation = Quaternion.Euler(0, 0, 0);
|
150
|
+
|
151
|
+
if (S == false)
|
152
|
+
|
153
|
+
{
|
154
|
+
|
155
|
+
if ((Input.GetKey(KeyCode.LeftShift))|| (Input.GetKey(KeyCode.RightShift)))
|
156
|
+
|
157
|
+
{
|
158
|
+
|
159
|
+
movespeed = 0.2f;
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
else
|
164
|
+
|
165
|
+
{
|
166
|
+
|
167
|
+
movespeed = 0.15f;
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
if (BattleS == true && EnCount == true && FieldNUM != 0)
|
172
|
+
|
173
|
+
{
|
174
|
+
|
175
|
+
Battle();
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
if (Input.GetKey(KeyCode.UpArrow) || (Input.GetKey(KeyCode.DownArrow) || (Input.GetKey(KeyCode.RightArrow) || (Input.GetKey(KeyCode.LeftArrow) || ((Input.GetKey(KeyCode.W) || (Input.GetKey(KeyCode.A) || (Input.GetKey(KeyCode.S) || (Input.GetKey(KeyCode.D))))))))))
|
180
|
+
|
181
|
+
{
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
if (AS== false)
|
186
|
+
|
187
|
+
{
|
188
|
+
|
189
|
+
this.animator.speed = (movespeed / 0.1f);
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
else
|
194
|
+
|
195
|
+
{
|
196
|
+
|
197
|
+
this.animator.speed = 0;
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
else
|
208
|
+
|
209
|
+
{
|
210
|
+
|
211
|
+
movespeed = 0;
|
212
|
+
|
213
|
+
this.animator.speed = 0;
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
//if (BattleS == true && EnCount == true && FieldNUM != 0)
|
218
|
+
|
219
|
+
//{
|
220
|
+
|
221
|
+
// Battle();
|
222
|
+
|
223
|
+
//}
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
else
|
228
|
+
|
229
|
+
{
|
230
|
+
|
231
|
+
movespeed = 0;
|
232
|
+
|
233
|
+
this.animator.speed = 0;
|
234
|
+
|
235
|
+
}
|
236
|
+
|
237
|
+
```
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
このコードでGameを実行すると、voidStartでSPRE.spriteをPDOWNに切り替えようとしているのですが、切り替わらずに、InspectorのspriterendererにはNoneが表示されます。
|
242
|
+
|
243
|
+
その時のアニメーターは、Entryの次のplayerに設定されていて、速度は0になっていました。
|