質問編集履歴
1
マイク入力ができているかもう一度確認したらできていませんでした。申し訳ありません。
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,11 +30,9 @@
|
|
30
30
|
|
31
31
|
|
32
32
|
|
33
|
-
```
|
33
|
+
```
|
34
|
-
|
35
|
-
|
34
|
+
|
36
|
-
|
37
|
-
|
35
|
+
using System;
|
38
36
|
|
39
37
|
using UnityEngine;
|
40
38
|
|
@@ -208,31 +206,211 @@
|
|
208
206
|
|
209
207
|
|
210
208
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
209
|
+
private void PlayLandingSound()
|
210
|
+
|
211
|
+
{
|
212
|
+
|
213
|
+
m_AudioSource.clip = m_LandSound;
|
214
|
+
|
215
|
+
m_AudioSource.Play();
|
216
|
+
|
217
|
+
m_NextStep = m_StepCycle + .5f;
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
private void FixedUpdate()
|
226
|
+
|
227
|
+
{
|
228
|
+
|
229
|
+
float speed;
|
230
|
+
|
231
|
+
GetInput(out speed);
|
232
|
+
|
233
|
+
// always move along the camera forward as it is the direction that it being aimed at
|
234
|
+
|
235
|
+
Vector3 desiredMove = transform.forward*m_Input.y + transform.right*m_Input.x;
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
// get a normal for the surface that is being touched to move along it
|
240
|
+
|
241
|
+
RaycastHit hitInfo;
|
242
|
+
|
243
|
+
Physics.SphereCast(transform.position, m_CharacterController.radius, Vector3.down, out hitInfo,
|
244
|
+
|
245
|
+
m_CharacterController.height/2f, Physics.AllLayers, QueryTriggerInteraction.Ignore);
|
246
|
+
|
247
|
+
desiredMove = Vector3.ProjectOnPlane(desiredMove, hitInfo.normal).normalized;
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
m_MoveDir.x = desiredMove.x*speed;
|
252
|
+
|
253
|
+
m_MoveDir.z = desiredMove.z*speed;
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
if (m_CharacterController.isGrounded)
|
260
|
+
|
261
|
+
{
|
262
|
+
|
263
|
+
m_MoveDir.y = -m_StickToGroundForce;
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
if (m_Jump)
|
268
|
+
|
269
|
+
{
|
270
|
+
|
271
|
+
m_MoveDir.y = m_JumpSpeed;
|
272
|
+
|
273
|
+
PlayJumpSound();
|
274
|
+
|
275
|
+
m_Jump = false;
|
276
|
+
|
277
|
+
m_Jumping = true;
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
}
|
282
|
+
|
283
|
+
else
|
284
|
+
|
285
|
+
{
|
286
|
+
|
287
|
+
m_MoveDir += Physics.gravity*m_GravityMultiplier*Time.fixedDeltaTime;
|
288
|
+
|
289
|
+
}
|
290
|
+
|
291
|
+
m_CollisionFlags = m_CharacterController.Move(m_MoveDir*Time.fixedDeltaTime);
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
ProgressStepCycle(speed);
|
296
|
+
|
297
|
+
UpdateCameraPosition(speed);
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
m_MouseLook.UpdateCursorLock();
|
302
|
+
|
303
|
+
}
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
.
|
310
|
+
|
311
|
+
.
|
312
|
+
|
313
|
+
.
|
314
|
+
|
315
|
+
.1万字を超えてしまったため一部省略
|
316
|
+
|
317
|
+
.
|
318
|
+
|
319
|
+
.
|
320
|
+
|
321
|
+
.
|
322
|
+
|
323
|
+
.
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
private void GetInput(out float speed)
|
328
|
+
|
329
|
+
{
|
330
|
+
|
331
|
+
// Read input
|
332
|
+
|
333
|
+
float horizontal = 0.0f;
|
334
|
+
|
335
|
+
float vertical = CrossPlatformInputManager.GetAxis("Vertical");
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
bool waswalking = m_IsWalking;
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
#if !MOBILE_INPUT
|
344
|
+
|
345
|
+
// On standalone builds, walk/run speed is modified by a key press.
|
346
|
+
|
347
|
+
// keep track of whether or not the character is walking or running
|
348
|
+
|
349
|
+
m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
|
350
|
+
|
351
|
+
#endif
|
352
|
+
|
353
|
+
// set the desired speed to be walking or running
|
354
|
+
|
355
|
+
speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
|
356
|
+
|
357
|
+
m_Input = new Vector2(horizontal, vertical);
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
// normalize input if it exceeds 1 in combined length:
|
362
|
+
|
363
|
+
if (m_Input.sqrMagnitude > 1)
|
364
|
+
|
365
|
+
{
|
366
|
+
|
367
|
+
m_Input.Normalize();
|
368
|
+
|
369
|
+
}
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
// handle speed change to give an fov kick
|
374
|
+
|
375
|
+
// only if the player is going to a run, is running and the fovkick is to be used
|
376
|
+
|
377
|
+
if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
|
378
|
+
|
379
|
+
{
|
380
|
+
|
381
|
+
StopAllCoroutines();
|
382
|
+
|
383
|
+
StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
|
384
|
+
|
385
|
+
}
|
386
|
+
|
387
|
+
}
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
private void RotateView()
|
394
|
+
|
395
|
+
{
|
396
|
+
|
397
|
+
m_MouseLook.LookRotation (transform, m_Camera.transform);
|
398
|
+
|
399
|
+
}
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
private void OnControllerColliderHit(ControllerColliderHit hit)
|
406
|
+
|
407
|
+
{
|
408
|
+
|
409
|
+
Rigidbody body = hit.collider.attachedRigidbody;
|
410
|
+
|
411
|
+
//dont move the rigidbody if the character is on top of it
|
412
|
+
|
413
|
+
if (m_CollisionFlags == CollisionFlags.Below)
|
236
414
|
|
237
415
|
{
|
238
416
|
|
@@ -240,127 +418,9 @@
|
|
240
418
|
|
241
419
|
}
|
242
420
|
|
243
|
-
|
421
|
+
|
244
|
-
|
245
|
-
|
422
|
+
|
246
|
-
|
247
|
-
m_Camera.transform.localPosition =
|
248
|
-
|
249
|
-
m_HeadBob.DoHeadBob(m_CharacterController.velocity.magnitude +
|
250
|
-
|
251
|
-
(speed*(m_IsWalking ? 1f : m_RunstepLenghten)));
|
252
|
-
|
253
|
-
newCameraPosition = m_Camera.transform.localPosition;
|
254
|
-
|
255
|
-
newCameraPosition.y = m_Camera.transform.localPosition.y - m_JumpBob.Offset();
|
256
|
-
|
257
|
-
}
|
258
|
-
|
259
|
-
else
|
260
|
-
|
261
|
-
{
|
262
|
-
|
263
|
-
newCameraPosition = m_Camera.transform.localPosition;
|
264
|
-
|
265
|
-
newCameraPosition.y = m_OriginalCameraPosition.y - m_JumpBob.Offset();
|
266
|
-
|
267
|
-
}
|
268
|
-
|
269
|
-
m_Camera.transform.localPosition = newCameraPosition;
|
270
|
-
|
271
|
-
}
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
private void GetInput(out float speed)
|
278
|
-
|
279
|
-
{
|
280
|
-
|
281
|
-
// Read input
|
282
|
-
|
283
|
-
float horizontal = 0.0f;
|
284
|
-
|
285
|
-
float vertical = CrossPlatformInputManager.GetAxis("Vertical");
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
bool waswalking = m_IsWalking;
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
#if !MOBILE_INPUT
|
294
|
-
|
295
|
-
// On standalone builds, walk/run speed is modified by a key press.
|
296
|
-
|
297
|
-
// keep track of whether or not the character is walking or running
|
298
|
-
|
299
|
-
m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
|
300
|
-
|
301
|
-
#endif
|
302
|
-
|
303
|
-
// set the desired speed to be walking or running
|
304
|
-
|
305
|
-
speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
|
306
|
-
|
307
|
-
m_Input = new Vector2(horizontal, vertical);
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
// normalize input if it exceeds 1 in combined length:
|
312
|
-
|
313
|
-
if (m_Input.sqrMagnitude > 1)
|
314
|
-
|
315
|
-
{
|
316
|
-
|
317
|
-
m_Input.Normalize();
|
318
|
-
|
319
|
-
}
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
// handle speed change to give an fov kick
|
324
|
-
|
325
|
-
// only if the player is going to a run, is running and the fovkick is to be used
|
326
|
-
|
327
|
-
if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
|
328
|
-
|
329
|
-
{
|
330
|
-
|
331
|
-
StopAllCoroutines();
|
332
|
-
|
333
|
-
StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
|
334
|
-
|
335
|
-
}
|
336
|
-
|
337
|
-
}
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
private void RotateView()
|
344
|
-
|
345
|
-
{
|
346
|
-
|
347
|
-
m_MouseLook.LookRotation (transform, m_Camera.transform);
|
348
|
-
|
349
|
-
}
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
private void OnControllerColliderHit(ControllerColliderHit hit)
|
356
|
-
|
357
|
-
{
|
358
|
-
|
359
|
-
Rigidbody body = hit.collider.attachedRigidbody;
|
360
|
-
|
361
|
-
//dont move the rigidbody if the character is on top of it
|
362
|
-
|
363
|
-
if (
|
423
|
+
if (body == null || body.isKinematic)
|
364
424
|
|
365
425
|
{
|
366
426
|
|
@@ -368,16 +428,6 @@
|
|
368
428
|
|
369
429
|
}
|
370
430
|
|
371
|
-
|
372
|
-
|
373
|
-
if (body == null || body.isKinematic)
|
374
|
-
|
375
|
-
{
|
376
|
-
|
377
|
-
return;
|
378
|
-
|
379
|
-
}
|
380
|
-
|
381
431
|
body.AddForceAtPosition(m_CharacterController.velocity*0.1f, hit.point, ForceMode.Impulse);
|
382
432
|
|
383
433
|
}
|
@@ -472,13 +522,15 @@
|
|
472
522
|
|
473
523
|
|
474
524
|
|
525
|
+
```
|
526
|
+
|
475
527
|
|
476
528
|
|
477
529
|
### 試したこと
|
478
530
|
|
479
531
|
|
480
532
|
|
481
|
-
|
533
|
+
|
482
534
|
|
483
535
|
|
484
536
|
|