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

質問編集履歴

9

mis

2020/04/15 16:30

投稿

hikaaaaaaaa
hikaaaaaaaa

スコア19

title CHANGED
File without changes
body CHANGED
@@ -61,270 +61,49 @@
61
61
  }
62
62
 
63
63
  ```
64
- プレイヤーの操作のためのスクリプト
64
+
65
+
65
66
  ```C#
67
+ using System.Collections;
68
+ using System.Collections.Generic;
66
69
  using UnityEngine;
67
70
  using UnityEngine.UI;
68
- using System.Collections;
69
- using System.Collections.Generic;
70
71
 
72
+ GameObject Player;
71
73
 
72
- namespace UnityStandardAssets.Characters.ThirdPerson
74
+ public class OniController : MonoBehaviour
73
75
  {
74
- [RequireComponent(typeof(Rigidbody))]
75
- [RequireComponent(typeof(CapsuleCollider))]
76
- [RequireComponent(typeof(Animator))]
77
- public class ThirdPersonCharacter : MonoBehaviour
78
- {
79
- [SerializeField] float m_MovingTurnSpeed = 360;
80
- [SerializeField] float m_StationaryTurnSpeed = 180;
81
- [SerializeField] float m_JumpPower = 12f;
82
- [Range(1f, 4f)][SerializeField] float m_GravityMultiplier = 2f;
83
- [SerializeField] float m_RunCycleLegOffset = 0.2f; //specific to the character in sample assets, will need to be modified to work with others
84
76
 
85
- float m_MoveSpeedMultiplier = 2.5f;
77
+ GameObject Player;
86
- [SerializeField] float m_AnimSpeedMultiplier = 1f;
87
- [SerializeField] float m_GroundCheckDistance = 0.1f;
88
78
 
89
- Rigidbody m_Rigidbody;
90
- Animator m_Animator;
91
- bool m_IsGrounded;
92
- float m_OrigGroundCheckDistance;
93
- const float k_Half = 0.5f;
94
- float m_TurnAmount;
95
- float m_ForwardAmount;
96
- Vector3 m_GroundNormal;
97
- float m_CapsuleHeight;
98
- Vector3 m_CapsuleCenter;
99
- CapsuleCollider m_Capsule;
100
- bool m_Crouching;
79
+ void Start()
80
+ {
81
+ this.Player = GameObject.Find("Player");
101
82
 
102
-
103
-
104
-
105
- void Start()
106
- {
107
- m_Animator = GetComponent<Animator>();
108
- m_Rigidbody = GetComponent<Rigidbody>();
109
- m_Capsule = GetComponent<CapsuleCollider>();
110
- m_CapsuleHeight = m_Capsule.height;
111
- m_CapsuleCenter = m_Capsule.center;
112
-
113
- m_Rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
114
- m_OrigGroundCheckDistance = m_GroundCheckDistance;
115
- }
116
-
117
83
 
118
84
 
119
- void OnTriggerEnter(Collider hit)
120
- {
121
- // 接触対象はPlayerタグですか?
122
- if (hit.CompareTag("Ham"))
123
- {
124
- m_MoveSpeedMultiplier = 5f;
125
- }
85
+ }
126
86
 
127
- Invoke("SpeedDown", 5);
128
- }
129
87
 
130
-
131
- public void SpeedDown()
88
+ public void OnCollisionEnter(Collider hit)
89
+ {
90
+ if (hit.CompareTag("Player"))
132
91
  {
133
- m_MoveSpeedMultiplier = 2.0f;
134
- }
135
92
 
136
-
137
-
138
-
139
- public void Move(Vector3 move, bool crouch, bool jump)
140
- {
141
93
 
94
+ int z = Random.Range(63, 64);
142
95
 
143
- // convert the world relative moveInput vector into a local-relative
144
- // turn amount and forward amount required to head in the desired
145
- // direction.
146
- if (move.magnitude > 1f) move.Normalize();
147
- move = transform.InverseTransformDirection(move);
96
+ this.Player.transform.position = new Vector3(4, 0, z);
148
- CheckGroundStatus();
149
- move = Vector3.ProjectOnPlane(move, m_GroundNormal);
150
- m_TurnAmount = Mathf.Atan2(move.x, move.z);
151
- m_ForwardAmount = move.z;
152
97
 
153
- ApplyExtraTurnRotation();
154
98
 
155
- // control and velocity handling is different when grounded and airborne:
156
- if (m_IsGrounded)
157
- {
158
- HandleGroundedMovement(crouch, jump);
159
- }
99
+ }
160
- else
161
- {
162
- HandleAirborneMovement();
163
- }
100
+ }
164
101
 
165
- ScaleCapsuleForCrouching(crouch);
166
- PreventStandingInLowHeadroom();
167
102
 
168
- // send input and other state parameters to the animator
169
- UpdateAnimator(move);
170
- }
171
103
 
172
-
173
- void ScaleCapsuleForCrouching(bool crouch)
174
- {
175
- if (m_IsGrounded && crouch)
176
- {
177
- if (m_Crouching) return;
178
- m_Capsule.height = m_Capsule.height / 2f;
179
- m_Capsule.center = m_Capsule.center / 2f;
180
- m_Crouching = true;
181
- }
182
- else
183
- {
184
- Ray crouchRay = new Ray(m_Rigidbody.position + Vector3.up * m_Capsule.radius * k_Half, Vector3.up);
185
- float crouchRayLength = m_CapsuleHeight - m_Capsule.radius * k_Half;
186
- if (Physics.SphereCast(crouchRay, m_Capsule.radius * k_Half, crouchRayLength, Physics.AllLayers, QueryTriggerInteraction.Ignore))
187
- {
188
- m_Crouching = true;
189
- return;
190
- }
191
- m_Capsule.height = m_CapsuleHeight;
192
- m_Capsule.center = m_CapsuleCenter;
193
- m_Crouching = false;
194
- }
195
- }
196
-
197
- void PreventStandingInLowHeadroom()
198
- {
199
- // prevent standing up in crouch-only zones
200
- if (!m_Crouching)
201
- {
202
- Ray crouchRay = new Ray(m_Rigidbody.position + Vector3.up * m_Capsule.radius * k_Half, Vector3.up);
203
- float crouchRayLength = m_CapsuleHeight - m_Capsule.radius * k_Half;
204
- if (Physics.SphereCast(crouchRay, m_Capsule.radius * k_Half, crouchRayLength, Physics.AllLayers, QueryTriggerInteraction.Ignore))
205
- {
206
- m_Crouching = true;
207
- }
208
- }
209
- }
210
-
211
-
212
- void UpdateAnimator(Vector3 move)
213
- {
214
- // update the animator parameters
215
- m_Animator.SetFloat("Forward", m_ForwardAmount, 0.1f, Time.deltaTime);
216
- m_Animator.SetFloat("Turn", m_TurnAmount, 0.1f, Time.deltaTime);
217
- m_Animator.SetBool("Crouch", m_Crouching);
218
- m_Animator.SetBool("OnGround", m_IsGrounded);
219
- if (!m_IsGrounded)
220
- {
221
- m_Animator.SetFloat("Jump", m_Rigidbody.velocity.y);
222
- }
223
-
224
- // calculate which leg is behind, so as to leave that leg trailing in the jump animation
225
- // (This code is reliant on the specific run cycle offset in our animations,
226
- // and assumes one leg passes the other at the normalized clip times of 0.0 and 0.5)
227
- float runCycle =
228
- Mathf.Repeat(
229
- m_Animator.GetCurrentAnimatorStateInfo(0).normalizedTime + m_RunCycleLegOffset, 1);
230
- float jumpLeg = (runCycle < k_Half ? 1 : -1) * m_ForwardAmount;
231
- if (m_IsGrounded)
232
- {
233
- m_Animator.SetFloat("JumpLeg", jumpLeg);
234
- }
235
-
236
- // the anim speed multiplier allows the overall speed of walking/running to be tweaked in the inspector,
237
- // which affects the movement speed because of the root motion.
238
- if (m_IsGrounded && move.magnitude > 0)
239
- {
240
- m_Animator.speed = m_AnimSpeedMultiplier;
241
-
242
-
243
- }
244
- else
245
- {
246
- // don't use that while airborne
247
- m_Animator.speed = 1;
248
- }
249
- }
250
-
251
-
252
- void HandleAirborneMovement()
253
- {
254
- // apply extra gravity from multiplier:
255
- Vector3 extraGravityForce = (Physics.gravity * m_GravityMultiplier) - Physics.gravity;
256
- m_Rigidbody.AddForce(extraGravityForce);
257
-
258
- m_GroundCheckDistance = m_Rigidbody.velocity.y < 0 ? m_OrigGroundCheckDistance : 0.01f;
259
- }
260
-
261
-
262
- void HandleGroundedMovement(bool crouch, bool jump)
263
- {
264
- // check whether conditions are right to allow a jump:
265
- if (jump && !crouch && m_Animator.GetCurrentAnimatorStateInfo(0).IsName("Grounded"))
266
- {
267
- // jump!
268
- m_Rigidbody.velocity = new Vector3(m_Rigidbody.velocity.x, m_JumpPower, m_Rigidbody.velocity.z);
269
- m_IsGrounded = false;
270
- m_Animator.applyRootMotion = false;
271
- m_GroundCheckDistance = 0.1f;
272
- }
273
- }
274
-
275
- void ApplyExtraTurnRotation()
276
- {
277
- // help the character turn faster (this is in addition to root rotation in the animation)
278
- float turnSpeed = Mathf.Lerp(m_StationaryTurnSpeed, m_MovingTurnSpeed, m_ForwardAmount);
279
- transform.Rotate(0, m_TurnAmount * turnSpeed * Time.deltaTime, 0);
280
- }
281
-
282
-
283
- public void OnAnimatorMove()
284
- {
285
- // we implement this function to override the default root motion.
286
- // this allows us to modify the positional speed before it's applied.
287
- if (m_IsGrounded && Time.deltaTime > 0)
288
- {
289
- Vector3 v = (m_Animator.deltaPosition * m_MoveSpeedMultiplier) / Time.deltaTime;
290
-
291
- // we preserve the existing y part of the current velocity.
292
- v.y = m_Rigidbody.velocity.y;
293
- m_Rigidbody.velocity = v;
294
-
295
-
296
-
297
- }
298
- }
299
-
300
-
301
- void CheckGroundStatus()
302
- {
303
- RaycastHit hitInfo;
304
- #if UNITY_EDITOR
305
- // helper to visualise the ground check ray in the scene view
306
- Debug.DrawLine(transform.position + (Vector3.up * 0.1f), transform.position + (Vector3.up * 0.1f) + (Vector3.down * m_GroundCheckDistance));
307
- #endif
308
- // 0.1f is a small offset to start the ray from inside the character
309
- // it is also good to note that the transform position in the sample assets is at the base of the character
310
- if (Physics.Raycast(transform.position + (Vector3.up * 0.1f), Vector3.down, out hitInfo, m_GroundCheckDistance))
311
- {
312
- m_GroundNormal = hitInfo.normal;
313
- m_IsGrounded = true;
314
- m_Animator.applyRootMotion = true;
315
- }
316
- else
317
- {
318
- m_IsGrounded = false;
319
- m_GroundNormal = Vector3.up;
320
- m_Animator.applyRootMotion = false;
321
- }
322
- }
323
- }
324
-
325
-
326
104
  }
327
-
105
+ ```
106
+ 訂正したスクリプト
328
107
  ```C#
329
108
  using System.Collections;
330
109
  using System.Collections.Generic;
@@ -347,9 +126,9 @@
347
126
  }
348
127
 
349
128
 
350
- public void OnCollisionEnter(Collider hit)
129
+ public void OnCollisionEnter(Collision hit)
351
130
  {
352
- if (hit.CompareTag("Player"))
131
+ if (hit.gameObject.tag == "Player"))
353
132
  {
354
133
 
355
134
 

8

m

2020/04/15 16:30

投稿

hikaaaaaaaa
hikaaaaaaaa

スコア19

title CHANGED
File without changes
body CHANGED
@@ -325,5 +325,43 @@
325
325
 
326
326
  }
327
327
 
328
- コード
328
+ ```C#
329
+ using System.Collections;
330
+ using System.Collections.Generic;
331
+ using UnityEngine;
332
+ using UnityEngine.UI;
333
+
334
+ GameObject Player;
335
+
336
+ public class OniController : MonoBehaviour
337
+ {
338
+
339
+ GameObject Player;
340
+
341
+ void Start()
342
+ {
343
+ this.Player = GameObject.Find("Player");
344
+
345
+
346
+
347
+ }
348
+
349
+
350
+ public void OnCollisionEnter(Collider hit)
351
+ {
352
+ if (hit.CompareTag("Player"))
353
+ {
354
+
355
+
356
+ int z = Random.Range(63, 64);
357
+
358
+ this.Player.transform.position = new Vector3(4, 0, z);
359
+
360
+
361
+ }
362
+ }
363
+
364
+
365
+
366
+ }
329
367
  ```

7

miiss

2020/04/15 16:03

投稿

hikaaaaaaaa
hikaaaaaaaa

スコア19

title CHANGED
@@ -1,1 +1,1 @@
1
- missプレイヤー同士の当たり判定について
1
+ プレイヤー同士の当たり判定について
body CHANGED
File without changes

6

miss

2020/04/15 14:11

投稿

hikaaaaaaaa
hikaaaaaaaa

スコア19

title CHANGED
File without changes
body CHANGED
@@ -18,6 +18,8 @@
18
18
  この落下の解決方法につきましてアドバイスをいただけますと幸いです。
19
19
  よろしくお願いいたします。
20
20
 
21
+
22
+ Oni側のスクリプト
21
23
  ```C#
22
24
  using System.Collections;
23
25
  using System.Collections.Generic;
@@ -59,6 +61,7 @@
59
61
  }
60
62
 
61
63
  ```
64
+ プレイヤーの操作のためのスクリプト
62
65
  ```C#
63
66
  using UnityEngine;
64
67
  using UnityEngine.UI;

5

miss

2020/04/15 14:00

投稿

hikaaaaaaaa
hikaaaaaaaa

スコア19

title CHANGED
File without changes
body CHANGED
@@ -58,4 +58,269 @@
58
58
 
59
59
  }
60
60
 
61
+ ```
62
+ ```C#
63
+ using UnityEngine;
64
+ using UnityEngine.UI;
65
+ using System.Collections;
66
+ using System.Collections.Generic;
67
+
68
+
69
+ namespace UnityStandardAssets.Characters.ThirdPerson
70
+ {
71
+ [RequireComponent(typeof(Rigidbody))]
72
+ [RequireComponent(typeof(CapsuleCollider))]
73
+ [RequireComponent(typeof(Animator))]
74
+ public class ThirdPersonCharacter : MonoBehaviour
75
+ {
76
+ [SerializeField] float m_MovingTurnSpeed = 360;
77
+ [SerializeField] float m_StationaryTurnSpeed = 180;
78
+ [SerializeField] float m_JumpPower = 12f;
79
+ [Range(1f, 4f)][SerializeField] float m_GravityMultiplier = 2f;
80
+ [SerializeField] float m_RunCycleLegOffset = 0.2f; //specific to the character in sample assets, will need to be modified to work with others
81
+
82
+ float m_MoveSpeedMultiplier = 2.5f;
83
+ [SerializeField] float m_AnimSpeedMultiplier = 1f;
84
+ [SerializeField] float m_GroundCheckDistance = 0.1f;
85
+
86
+ Rigidbody m_Rigidbody;
87
+ Animator m_Animator;
88
+ bool m_IsGrounded;
89
+ float m_OrigGroundCheckDistance;
90
+ const float k_Half = 0.5f;
91
+ float m_TurnAmount;
92
+ float m_ForwardAmount;
93
+ Vector3 m_GroundNormal;
94
+ float m_CapsuleHeight;
95
+ Vector3 m_CapsuleCenter;
96
+ CapsuleCollider m_Capsule;
97
+ bool m_Crouching;
98
+
99
+
100
+
101
+
102
+ void Start()
103
+ {
104
+ m_Animator = GetComponent<Animator>();
105
+ m_Rigidbody = GetComponent<Rigidbody>();
106
+ m_Capsule = GetComponent<CapsuleCollider>();
107
+ m_CapsuleHeight = m_Capsule.height;
108
+ m_CapsuleCenter = m_Capsule.center;
109
+
110
+ m_Rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
111
+ m_OrigGroundCheckDistance = m_GroundCheckDistance;
112
+ }
113
+
114
+
115
+
116
+ void OnTriggerEnter(Collider hit)
117
+ {
118
+ // 接触対象はPlayerタグですか?
119
+ if (hit.CompareTag("Ham"))
120
+ {
121
+ m_MoveSpeedMultiplier = 5f;
122
+ }
123
+
124
+ Invoke("SpeedDown", 5);
125
+ }
126
+
127
+
128
+ public void SpeedDown()
129
+ {
130
+ m_MoveSpeedMultiplier = 2.0f;
131
+ }
132
+
133
+
134
+
135
+
136
+ public void Move(Vector3 move, bool crouch, bool jump)
137
+ {
138
+
139
+
140
+ // convert the world relative moveInput vector into a local-relative
141
+ // turn amount and forward amount required to head in the desired
142
+ // direction.
143
+ if (move.magnitude > 1f) move.Normalize();
144
+ move = transform.InverseTransformDirection(move);
145
+ CheckGroundStatus();
146
+ move = Vector3.ProjectOnPlane(move, m_GroundNormal);
147
+ m_TurnAmount = Mathf.Atan2(move.x, move.z);
148
+ m_ForwardAmount = move.z;
149
+
150
+ ApplyExtraTurnRotation();
151
+
152
+ // control and velocity handling is different when grounded and airborne:
153
+ if (m_IsGrounded)
154
+ {
155
+ HandleGroundedMovement(crouch, jump);
156
+ }
157
+ else
158
+ {
159
+ HandleAirborneMovement();
160
+ }
161
+
162
+ ScaleCapsuleForCrouching(crouch);
163
+ PreventStandingInLowHeadroom();
164
+
165
+ // send input and other state parameters to the animator
166
+ UpdateAnimator(move);
167
+ }
168
+
169
+
170
+ void ScaleCapsuleForCrouching(bool crouch)
171
+ {
172
+ if (m_IsGrounded && crouch)
173
+ {
174
+ if (m_Crouching) return;
175
+ m_Capsule.height = m_Capsule.height / 2f;
176
+ m_Capsule.center = m_Capsule.center / 2f;
177
+ m_Crouching = true;
178
+ }
179
+ else
180
+ {
181
+ Ray crouchRay = new Ray(m_Rigidbody.position + Vector3.up * m_Capsule.radius * k_Half, Vector3.up);
182
+ float crouchRayLength = m_CapsuleHeight - m_Capsule.radius * k_Half;
183
+ if (Physics.SphereCast(crouchRay, m_Capsule.radius * k_Half, crouchRayLength, Physics.AllLayers, QueryTriggerInteraction.Ignore))
184
+ {
185
+ m_Crouching = true;
186
+ return;
187
+ }
188
+ m_Capsule.height = m_CapsuleHeight;
189
+ m_Capsule.center = m_CapsuleCenter;
190
+ m_Crouching = false;
191
+ }
192
+ }
193
+
194
+ void PreventStandingInLowHeadroom()
195
+ {
196
+ // prevent standing up in crouch-only zones
197
+ if (!m_Crouching)
198
+ {
199
+ Ray crouchRay = new Ray(m_Rigidbody.position + Vector3.up * m_Capsule.radius * k_Half, Vector3.up);
200
+ float crouchRayLength = m_CapsuleHeight - m_Capsule.radius * k_Half;
201
+ if (Physics.SphereCast(crouchRay, m_Capsule.radius * k_Half, crouchRayLength, Physics.AllLayers, QueryTriggerInteraction.Ignore))
202
+ {
203
+ m_Crouching = true;
204
+ }
205
+ }
206
+ }
207
+
208
+
209
+ void UpdateAnimator(Vector3 move)
210
+ {
211
+ // update the animator parameters
212
+ m_Animator.SetFloat("Forward", m_ForwardAmount, 0.1f, Time.deltaTime);
213
+ m_Animator.SetFloat("Turn", m_TurnAmount, 0.1f, Time.deltaTime);
214
+ m_Animator.SetBool("Crouch", m_Crouching);
215
+ m_Animator.SetBool("OnGround", m_IsGrounded);
216
+ if (!m_IsGrounded)
217
+ {
218
+ m_Animator.SetFloat("Jump", m_Rigidbody.velocity.y);
219
+ }
220
+
221
+ // calculate which leg is behind, so as to leave that leg trailing in the jump animation
222
+ // (This code is reliant on the specific run cycle offset in our animations,
223
+ // and assumes one leg passes the other at the normalized clip times of 0.0 and 0.5)
224
+ float runCycle =
225
+ Mathf.Repeat(
226
+ m_Animator.GetCurrentAnimatorStateInfo(0).normalizedTime + m_RunCycleLegOffset, 1);
227
+ float jumpLeg = (runCycle < k_Half ? 1 : -1) * m_ForwardAmount;
228
+ if (m_IsGrounded)
229
+ {
230
+ m_Animator.SetFloat("JumpLeg", jumpLeg);
231
+ }
232
+
233
+ // the anim speed multiplier allows the overall speed of walking/running to be tweaked in the inspector,
234
+ // which affects the movement speed because of the root motion.
235
+ if (m_IsGrounded && move.magnitude > 0)
236
+ {
237
+ m_Animator.speed = m_AnimSpeedMultiplier;
238
+
239
+
240
+ }
241
+ else
242
+ {
243
+ // don't use that while airborne
244
+ m_Animator.speed = 1;
245
+ }
246
+ }
247
+
248
+
249
+ void HandleAirborneMovement()
250
+ {
251
+ // apply extra gravity from multiplier:
252
+ Vector3 extraGravityForce = (Physics.gravity * m_GravityMultiplier) - Physics.gravity;
253
+ m_Rigidbody.AddForce(extraGravityForce);
254
+
255
+ m_GroundCheckDistance = m_Rigidbody.velocity.y < 0 ? m_OrigGroundCheckDistance : 0.01f;
256
+ }
257
+
258
+
259
+ void HandleGroundedMovement(bool crouch, bool jump)
260
+ {
261
+ // check whether conditions are right to allow a jump:
262
+ if (jump && !crouch && m_Animator.GetCurrentAnimatorStateInfo(0).IsName("Grounded"))
263
+ {
264
+ // jump!
265
+ m_Rigidbody.velocity = new Vector3(m_Rigidbody.velocity.x, m_JumpPower, m_Rigidbody.velocity.z);
266
+ m_IsGrounded = false;
267
+ m_Animator.applyRootMotion = false;
268
+ m_GroundCheckDistance = 0.1f;
269
+ }
270
+ }
271
+
272
+ void ApplyExtraTurnRotation()
273
+ {
274
+ // help the character turn faster (this is in addition to root rotation in the animation)
275
+ float turnSpeed = Mathf.Lerp(m_StationaryTurnSpeed, m_MovingTurnSpeed, m_ForwardAmount);
276
+ transform.Rotate(0, m_TurnAmount * turnSpeed * Time.deltaTime, 0);
277
+ }
278
+
279
+
280
+ public void OnAnimatorMove()
281
+ {
282
+ // we implement this function to override the default root motion.
283
+ // this allows us to modify the positional speed before it's applied.
284
+ if (m_IsGrounded && Time.deltaTime > 0)
285
+ {
286
+ Vector3 v = (m_Animator.deltaPosition * m_MoveSpeedMultiplier) / Time.deltaTime;
287
+
288
+ // we preserve the existing y part of the current velocity.
289
+ v.y = m_Rigidbody.velocity.y;
290
+ m_Rigidbody.velocity = v;
291
+
292
+
293
+
294
+ }
295
+ }
296
+
297
+
298
+ void CheckGroundStatus()
299
+ {
300
+ RaycastHit hitInfo;
301
+ #if UNITY_EDITOR
302
+ // helper to visualise the ground check ray in the scene view
303
+ Debug.DrawLine(transform.position + (Vector3.up * 0.1f), transform.position + (Vector3.up * 0.1f) + (Vector3.down * m_GroundCheckDistance));
304
+ #endif
305
+ // 0.1f is a small offset to start the ray from inside the character
306
+ // it is also good to note that the transform position in the sample assets is at the base of the character
307
+ if (Physics.Raycast(transform.position + (Vector3.up * 0.1f), Vector3.down, out hitInfo, m_GroundCheckDistance))
308
+ {
309
+ m_GroundNormal = hitInfo.normal;
310
+ m_IsGrounded = true;
311
+ m_Animator.applyRootMotion = true;
312
+ }
313
+ else
314
+ {
315
+ m_IsGrounded = false;
316
+ m_GroundNormal = Vector3.up;
317
+ m_Animator.applyRootMotion = false;
318
+ }
319
+ }
320
+ }
321
+
322
+
323
+ }
324
+
325
+ コード
61
326
  ```

4

miss

2020/04/15 13:24

投稿

hikaaaaaaaa
hikaaaaaaaa

スコア19

title CHANGED
@@ -1,1 +1,1 @@
1
- プレイヤー同士の当たり判定について
1
+ missプレイヤー同士の当たり判定について
body CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
  その際に鬼に捕まった際にはプレイヤーが所定の場所に移動するというスクリプトを書きました。
10
- プレイヤーのコライダーをtrueにしておくと落下するので、Playerの子要素(Playerとobject名を統一させました。)にコライダーを加え、トリガーをtrueにし、タグをPlayerとすることで実装を行いました。
10
+ RigidBodyがアタッチされているプレイヤーのコライダーのトリガーをtrueにしておくと落下するので、Playerの子要素(Playerとobject名を統一させました。)にコライダーを加え、トリガーをtrueにし、タグをPlayerとすることで実装を行いました。
11
11
 
12
12
  その場合移動はされるのですが、やはりキャラクターが落下してしまう問題が発生しました。
13
13
 

3

2020/04/15 13:06

投稿

hikaaaaaaaa
hikaaaaaaaa

スコア19

title CHANGED
File without changes
body CHANGED
@@ -15,7 +15,7 @@
15
15
  鬼がPlayerに追いついて、ボタンを押した際にPlayerを所定の場所に送るように書き変える予定であることと、
16
16
  あるタイミングでもう一度復活をするようなゲームにしたいと考えているので、その方法では実装できませんでした。
17
17
 
18
- この落下の解決方法につきましてアドバイスいただけますと幸いです。
18
+ この落下の解決方法につきましてアドバイスいただけますと幸いです。
19
19
  よろしくお願いいたします。
20
20
 
21
21
  ```C#

2

miss

2020/04/15 12:00

投稿

hikaaaaaaaa
hikaaaaaaaa

スコア19

title CHANGED
File without changes
body CHANGED
@@ -12,7 +12,7 @@
12
12
  その場合移動はされるのですが、やはりキャラクターが落下してしまう問題が発生しました。
13
13
 
14
14
  プレーヤー側にスクリプトを組みiskinematicをtureにすることで落下を防ぐことも考えましたが
15
- 鬼がplyerに追いついて、ボタンを押した際にPlayerを所定の場所に送るように書き変える予定であることと、
15
+ 鬼がPlayerに追いついて、ボタンを押した際にPlayerを所定の場所に送るように書き変える予定であることと、
16
16
  あるタイミングでもう一度復活をするようなゲームにしたいと考えているので、その方法では実装できませんでした。
17
17
 
18
18
  この落下の解決方法につきましてアドバイスといただけますと幸いです。

1

ごじ

2020/04/15 11:42

投稿

hikaaaaaaaa
hikaaaaaaaa

スコア19

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,8 @@
1
1
  unity3Dで鬼ごっこのゲームを作成しています。
2
2
 
3
+ プレイヤー同士がぶつかった際の当たり判定を試みるとトリガーをtrueにした方のプレイヤーが落下してしまいます。
4
+ 様々な記事を読んで見ましたが自力での解決ができなかったため質問させていただきました。
5
+
3
6
  [Standerd Aseetes](https://assetstore.unity.com/packages/essentials/asset-packs/standard-assets-for-unity-2017-3-32351?locale=ja-JP)を用いてプレイヤーを複製し、スクリプトを書き換えることで鬼を作成しoniを作成しました。Playerはそのまま逃げる側で使用をしております。
4
7
 
5
8