Skip to content

Commit efb2996

Browse files
authored
Slime critter propel attack (#315)
1 parent 5cc63e0 commit efb2996

File tree

7 files changed

+11756
-38
lines changed

7 files changed

+11756
-38
lines changed

UOP1_Project/Assets/Art/Characters/SlimeCritter/Animation/Attack.anim

Lines changed: 11623 additions & 0 deletions
Large diffs are not rendered by default.

UOP1_Project/Assets/Art/Characters/SlimeCritter/Animation/Attack.anim.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UOP1_Project/Assets/Art/Characters/SlimeCritter/Animation/SlimeCritter.controller

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,37 +242,37 @@ AnimatorController:
242242
m_DefaultFloat: 0
243243
m_DefaultInt: 0
244244
m_DefaultBool: 0
245-
m_Controller: {fileID: 0}
245+
m_Controller: {fileID: 9100000}
246246
- m_Name: Attack
247247
m_Type: 9
248248
m_DefaultFloat: 0
249249
m_DefaultInt: 0
250250
m_DefaultBool: 0
251-
m_Controller: {fileID: 0}
251+
m_Controller: {fileID: 9100000}
252252
- m_Name: IsDead
253253
m_Type: 9
254254
m_DefaultFloat: 0
255255
m_DefaultInt: 0
256256
m_DefaultBool: 0
257-
m_Controller: {fileID: 0}
257+
m_Controller: {fileID: 9100000}
258258
- m_Name: idlebr
259259
m_Type: 9
260260
m_DefaultFloat: 0
261261
m_DefaultInt: 0
262262
m_DefaultBool: 0
263-
m_Controller: {fileID: 0}
263+
m_Controller: {fileID: 9100000}
264264
- m_Name: GetHit
265265
m_Type: 9
266266
m_DefaultFloat: 0
267267
m_DefaultInt: 0
268268
m_DefaultBool: 0
269-
m_Controller: {fileID: 0}
269+
m_Controller: {fileID: 9100000}
270270
- m_Name: IsMoving
271271
m_Type: 4
272272
m_DefaultFloat: 0
273273
m_DefaultInt: 0
274274
m_DefaultBool: 0
275-
m_Controller: {fileID: 0}
275+
m_Controller: {fileID: 9100000}
276276
m_AnimatorLayers:
277277
- serializedVersion: 5
278278
m_Name: Base Layer
@@ -448,8 +448,7 @@ AnimatorState:
448448
m_MirrorParameterActive: 0
449449
m_CycleOffsetParameterActive: 0
450450
m_TimeParameterActive: 0
451-
m_Motion: {fileID: -2106478572821700557, guid: 52ff7facc4957e944815ef86a2669a4a,
452-
type: 3}
451+
m_Motion: {fileID: 7400000, guid: 051e79817c3456c48bf1136efa5911d7, type: 2}
453452
m_Tag:
454453
m_SpeedParameter:
455454
m_MirrorParameter:

UOP1_Project/Assets/Prefabs/Characters/SlimeCritter_Base.prefab

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,21 @@ MonoBehaviour:
8181
_critterSO: {fileID: 11400000, guid: fd7717100e602c446847524419231170, type: 2}
8282
_collectibleItemPrefab: {fileID: 2126586097156616357, guid: 0f60adbc96570cb4e9898a0409956f1d,
8383
type: 3}
84+
--- !u!114 &2038924309811281612
85+
MonoBehaviour:
86+
m_ObjectHideFlags: 0
87+
m_CorrespondingSourceObject: {fileID: 0}
88+
m_PrefabInstance: {fileID: 0}
89+
m_PrefabAsset: {fileID: 0}
90+
m_GameObject: {fileID: 8687264390989375961}
91+
m_Enabled: 1
92+
m_EditorHideFlags: 0
93+
m_Script: {fileID: 11500000, guid: 95216bcd641df05419665f7db9aed05b, type: 3}
94+
m_Name:
95+
m_EditorClassIdentifier:
96+
_playerTransform: {fileID: 11400000, guid: 35fc4039342b6ba458d0d4429e89ee74, type: 2}
97+
_propelFactor: 1
98+
_propelDuration: 0.2
8499
--- !u!1001 &2135821800440209491
85100
PrefabInstance:
86101
m_ObjectHideFlags: 0
@@ -103,6 +118,11 @@ PrefabInstance:
103118
propertyPath: _enterZone.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
104119
value: set_isPlayerInAttackZone
105120
objectReference: {fileID: 0}
121+
- target: {fileID: 96998187169542726, guid: c823b09b59e206649a8779a78929fa2d,
122+
type: 3}
123+
propertyPath: m_RootOrder
124+
value: 3
125+
objectReference: {fileID: 0}
106126
- target: {fileID: 96998187169542726, guid: c823b09b59e206649a8779a78929fa2d,
107127
type: 3}
108128
propertyPath: m_LocalPosition.x
@@ -118,6 +138,11 @@ PrefabInstance:
118138
propertyPath: m_LocalPosition.z
119139
value: 0
120140
objectReference: {fileID: 0}
141+
- target: {fileID: 96998187169542726, guid: c823b09b59e206649a8779a78929fa2d,
142+
type: 3}
143+
propertyPath: m_LocalRotation.w
144+
value: 1
145+
objectReference: {fileID: 0}
121146
- target: {fileID: 96998187169542726, guid: c823b09b59e206649a8779a78929fa2d,
122147
type: 3}
123148
propertyPath: m_LocalRotation.x
@@ -133,16 +158,6 @@ PrefabInstance:
133158
propertyPath: m_LocalRotation.z
134159
value: 0
135160
objectReference: {fileID: 0}
136-
- target: {fileID: 96998187169542726, guid: c823b09b59e206649a8779a78929fa2d,
137-
type: 3}
138-
propertyPath: m_LocalRotation.w
139-
value: 1
140-
objectReference: {fileID: 0}
141-
- target: {fileID: 96998187169542726, guid: c823b09b59e206649a8779a78929fa2d,
142-
type: 3}
143-
propertyPath: m_RootOrder
144-
value: 3
145-
objectReference: {fileID: 0}
146161
- target: {fileID: 96998187169542726, guid: c823b09b59e206649a8779a78929fa2d,
147162
type: 3}
148163
propertyPath: m_LocalEulerAnglesHint.x
@@ -182,6 +197,11 @@ PrefabInstance:
182197
propertyPath: _enterZone.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
183198
value: set_isPlayerInAlertZone
184199
objectReference: {fileID: 0}
200+
- target: {fileID: 96998187169542726, guid: c823b09b59e206649a8779a78929fa2d,
201+
type: 3}
202+
propertyPath: m_RootOrder
203+
value: 2
204+
objectReference: {fileID: 0}
185205
- target: {fileID: 96998187169542726, guid: c823b09b59e206649a8779a78929fa2d,
186206
type: 3}
187207
propertyPath: m_LocalPosition.x
@@ -197,6 +217,11 @@ PrefabInstance:
197217
propertyPath: m_LocalPosition.z
198218
value: 0
199219
objectReference: {fileID: 0}
220+
- target: {fileID: 96998187169542726, guid: c823b09b59e206649a8779a78929fa2d,
221+
type: 3}
222+
propertyPath: m_LocalRotation.w
223+
value: 1
224+
objectReference: {fileID: 0}
200225
- target: {fileID: 96998187169542726, guid: c823b09b59e206649a8779a78929fa2d,
201226
type: 3}
202227
propertyPath: m_LocalRotation.x
@@ -212,16 +237,6 @@ PrefabInstance:
212237
propertyPath: m_LocalRotation.z
213238
value: 0
214239
objectReference: {fileID: 0}
215-
- target: {fileID: 96998187169542726, guid: c823b09b59e206649a8779a78929fa2d,
216-
type: 3}
217-
propertyPath: m_LocalRotation.w
218-
value: 1
219-
objectReference: {fileID: 0}
220-
- target: {fileID: 96998187169542726, guid: c823b09b59e206649a8779a78929fa2d,
221-
type: 3}
222-
propertyPath: m_RootOrder
223-
value: 2
224-
objectReference: {fileID: 0}
225240
- target: {fileID: 96998187169542726, guid: c823b09b59e206649a8779a78929fa2d,
226241
type: 3}
227242
propertyPath: m_LocalEulerAnglesHint.x
@@ -253,42 +268,42 @@ PrefabInstance:
253268
m_Modifications:
254269
- target: {fileID: -8679921383154817045, guid: 63937395ff7a888419d4b8fe450d3c91,
255270
type: 3}
256-
propertyPath: m_LocalPosition.x
271+
propertyPath: m_RootOrder
257272
value: 0
258273
objectReference: {fileID: 0}
259274
- target: {fileID: -8679921383154817045, guid: 63937395ff7a888419d4b8fe450d3c91,
260275
type: 3}
261-
propertyPath: m_LocalPosition.y
276+
propertyPath: m_LocalPosition.x
262277
value: 0
263278
objectReference: {fileID: 0}
264279
- target: {fileID: -8679921383154817045, guid: 63937395ff7a888419d4b8fe450d3c91,
265280
type: 3}
266-
propertyPath: m_LocalPosition.z
281+
propertyPath: m_LocalPosition.y
267282
value: 0
268283
objectReference: {fileID: 0}
269284
- target: {fileID: -8679921383154817045, guid: 63937395ff7a888419d4b8fe450d3c91,
270285
type: 3}
271-
propertyPath: m_LocalRotation.x
286+
propertyPath: m_LocalPosition.z
272287
value: 0
273288
objectReference: {fileID: 0}
274289
- target: {fileID: -8679921383154817045, guid: 63937395ff7a888419d4b8fe450d3c91,
275290
type: 3}
276-
propertyPath: m_LocalRotation.y
277-
value: 0
291+
propertyPath: m_LocalRotation.w
292+
value: 1
278293
objectReference: {fileID: 0}
279294
- target: {fileID: -8679921383154817045, guid: 63937395ff7a888419d4b8fe450d3c91,
280295
type: 3}
281-
propertyPath: m_LocalRotation.z
296+
propertyPath: m_LocalRotation.x
282297
value: 0
283298
objectReference: {fileID: 0}
284299
- target: {fileID: -8679921383154817045, guid: 63937395ff7a888419d4b8fe450d3c91,
285300
type: 3}
286-
propertyPath: m_LocalRotation.w
287-
value: 1
301+
propertyPath: m_LocalRotation.y
302+
value: 0
288303
objectReference: {fileID: 0}
289304
- target: {fileID: -8679921383154817045, guid: 63937395ff7a888419d4b8fe450d3c91,
290305
type: 3}
291-
propertyPath: m_RootOrder
306+
propertyPath: m_LocalRotation.z
292307
value: 0
293308
objectReference: {fileID: 0}
294309
- target: {fileID: -8679921383154817045, guid: 63937395ff7a888419d4b8fe450d3c91,
@@ -311,6 +326,11 @@ PrefabInstance:
311326
propertyPath: m_Name
312327
value: SlimeCritter_Base
313328
objectReference: {fileID: 0}
329+
- target: {fileID: 1430996729439901540, guid: 63937395ff7a888419d4b8fe450d3c91,
330+
type: 3}
331+
propertyPath: m_RootBone
332+
value:
333+
objectReference: {fileID: 6359161719296748449}
314334
- target: {fileID: 5866666021909216657, guid: 63937395ff7a888419d4b8fe450d3c91,
315335
type: 3}
316336
propertyPath: m_Controller
@@ -330,3 +350,9 @@ Transform:
330350
type: 3}
331351
m_PrefabInstance: {fileID: 8380694498511901832}
332352
m_PrefabAsset: {fileID: 0}
353+
--- !u!4 &6359161719296748449 stripped
354+
Transform:
355+
m_CorrespondingSourceObject: {fileID: -6048770967118889175, guid: 63937395ff7a888419d4b8fe450d3c91,
356+
type: 3}
357+
m_PrefabInstance: {fileID: 8380694498511901832}
358+
m_PrefabAsset: {fileID: 0}

UOP1_Project/Assets/ProBuilder Data.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class SlimeCritterAttackController : MonoBehaviour
6+
{
7+
// Reference of the player transform to compute the propel target position
8+
[SerializeField]
9+
private TransformAnchor _playerTransform;
10+
11+
// Propel factor is the proportion of the distance between the critter and the player crossed by the critter during the propel animation
12+
[SerializeField]
13+
private float _propelFactor = 1.0f;
14+
15+
// Duration of the propel section of the animation.
16+
[SerializeField]
17+
private float _propelDuration = 0.2f;
18+
19+
private float _innerTime = 0.0f;
20+
private Vector3 _propelTargetVector = default;
21+
22+
// When the attack starts, the position targeted by the attack is determined and is not changed afterward
23+
public void SetAttackTarget()
24+
{
25+
_propelTargetVector = (_playerTransform.Transform.position - transform.position) * _propelFactor / _propelDuration;
26+
}
27+
28+
// Trigger the propel movement during the attack
29+
public void AttackPropelTrigger()
30+
{
31+
_innerTime = _propelDuration;
32+
}
33+
34+
// Update is called once per frame
35+
void Update()
36+
{
37+
if (_innerTime > 0)
38+
{
39+
transform.position += _propelTargetVector * Time.deltaTime;
40+
_innerTime -= Time.deltaTime;
41+
}
42+
}
43+
}

UOP1_Project/Assets/Scripts/Characters/SlimeCritterAttackController.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)