Skip to content

Commit 764a324

Browse files
committed
update the direction when the animation is changed
1 parent 246cd5c commit 764a324

File tree

1 file changed

+131
-111
lines changed

1 file changed

+131
-111
lines changed

extensions/community/TopDownMovementAnimator.json

Lines changed: 131 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,19 @@
225225
]
226226
}
227227
],
228-
"actions": [],
228+
"actions": [
229+
{
230+
"type": {
231+
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationDirection"
232+
},
233+
"parameters": [
234+
"Object",
235+
"Behavior",
236+
"NewAnimationDirection",
237+
""
238+
]
239+
}
240+
],
229241
"events": [
230242
{
231243
"type": "BuiltinCommonInstructions::Standard",
@@ -244,7 +256,7 @@
244256
"actions": [
245257
{
246258
"type": {
247-
"value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationPause"
259+
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationPause"
248260
},
249261
"parameters": [
250262
"Object",
@@ -271,7 +283,7 @@
271283
"actions": [
272284
{
273285
"type": {
274-
"value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationSpeedScale"
286+
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationSpeedScale"
275287
},
276288
"parameters": [
277289
"Object",
@@ -280,72 +292,6 @@
280292
]
281293
}
282294
]
283-
},
284-
{
285-
"type": "BuiltinCommonInstructions::Standard",
286-
"conditions": [],
287-
"actions": [
288-
{
289-
"type": {
290-
"value": "SetNumberVariable"
291-
},
292-
"parameters": [
293-
"NewAnimationDirection",
294-
"=",
295-
"Object.Behavior::Direction()"
296-
]
297-
}
298-
],
299-
"events": [
300-
{
301-
"type": "BuiltinCommonInstructions::Comment",
302-
"color": {
303-
"b": 109,
304-
"g": 230,
305-
"r": 255,
306-
"textB": 0,
307-
"textG": 0,
308-
"textR": 0
309-
},
310-
"comment": "Use a small margin is used to avoid to flicker between 2 directions."
311-
},
312-
{
313-
"type": "BuiltinCommonInstructions::Standard",
314-
"conditions": [
315-
{
316-
"type": {
317-
"value": "BuiltinCommonInstructions::CompareNumbers"
318-
},
319-
"parameters": [
320-
"abs(Object.Behavior::DirectionDifference(NewAnimationDirection, AnimationDirection))",
321-
">",
322-
"0.5 + 0.03125"
323-
]
324-
}
325-
],
326-
"actions": [
327-
{
328-
"type": {
329-
"value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationDirection"
330-
},
331-
"parameters": [
332-
"Object",
333-
"Behavior",
334-
"NewAnimationDirection",
335-
""
336-
]
337-
}
338-
]
339-
}
340-
],
341-
"variables": [
342-
{
343-
"folded": true,
344-
"name": "NewAnimationDirection",
345-
"type": "number",
346-
"value": 0
347-
}
348-
]
349295
}
350296
]
351297
}
@@ -412,6 +358,18 @@
412358
"name": "SetAnimationName",
413359
"sentence": "",
414360
"events": [
361+
{
362+
"type": "BuiltinCommonInstructions::Comment",
363+
"color": {
364+
"b": 109,
365+
"g": 230,
366+
"r": 255,
367+
"textB": 0,
368+
"textG": 0,
369+
"textR": 0
370+
},
371+
"comment": "Also update the animation direction to avoid to play the animation in an old direction for 1 frame."
372+
},
415373
{
416374
"type": "BuiltinCommonInstructions::Standard",
417375
"conditions": [
@@ -446,6 +404,17 @@
446404
"Behavior",
447405
""
448406
]
407+
},
408+
{
409+
"type": {
410+
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationDirection"
411+
},
412+
"parameters": [
413+
"Object",
414+
"Behavior",
415+
"NewAnimationDirection",
416+
""
417+
]
449418
}
450419
]
451420
}
@@ -583,7 +552,7 @@
583552
},
584553
{
585554
"type": {
586-
"value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationPause"
555+
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationPause"
587556
},
588557
"parameters": [
589558
"Object",
@@ -737,7 +706,7 @@
737706
},
738707
{
739708
"type": {
740-
"value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationSpeedScale"
709+
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationSpeedScale"
741710
},
742711
"parameters": [
743712
"Object",
@@ -774,7 +743,7 @@
774743
"description": "Change the animation speed scale according to the object speed.",
775744
"fullName": "Animation speed scale",
776745
"functionType": "Action",
777-
"name": "SetAnimationSpeedScale",
746+
"name": "UpdateAnimationSpeedScale",
778747
"private": true,
779748
"sentence": "Change the animation speed scale according to _PARAM0_ speed",
780749
"events": [
@@ -856,7 +825,7 @@
856825
"description": "Pause the animation according to the object speed.",
857826
"fullName": "Animation pause",
858827
"functionType": "Action",
859-
"name": "SetAnimationPause",
828+
"name": "UpdateAnimationPause",
860829
"private": true,
861830
"sentence": "Pause the animation according to _PARAM0_ speed",
862831
"events": [
@@ -1023,12 +992,12 @@
1023992
"objectGroups": []
1024993
},
1025994
{
1026-
"description": "Change the animation direction of the object.",
1027-
"fullName": "Animation name and direction",
995+
"description": "Update the animation direction of the object.",
996+
"fullName": "Update animation direction",
1028997
"functionType": "Action",
1029-
"name": "SetAnimationDirection",
998+
"name": "UpdateAnimationDirection",
1030999
"private": true,
1031-
"sentence": "Change the animation direction of _PARAM0_ to _PARAM2_",
1000+
"sentence": "Update the animation direction of _PARAM0_",
10321001
"events": [
10331002
{
10341003
"type": "BuiltinCommonInstructions::Comment",
@@ -1051,47 +1020,103 @@
10511020
"value": "SetNumberVariable"
10521021
},
10531022
"parameters": [
1054-
"AnimationDirection",
1023+
"NewAnimationDirection",
10551024
"=",
1056-
"mod(mod(round(NewDirection), DirectionCount) + DirectionCount, DirectionCount)"
1025+
"Object.Behavior::Direction()"
10571026
]
1058-
},
1059-
{
1060-
"type": {
1061-
"value": "SetNumberVariable"
1062-
},
1063-
"parameters": [
1064-
"AnimationElapsedTime",
1065-
"=",
1066-
"Object.Animation::ElapsedTime()"
1067-
]
1068-
},
1027+
}
1028+
],
1029+
"events": [
10691030
{
1070-
"type": {
1071-
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationName"
1031+
"type": "BuiltinCommonInstructions::Comment",
1032+
"color": {
1033+
"b": 109,
1034+
"g": 230,
1035+
"r": 255,
1036+
"textB": 0,
1037+
"textG": 0,
1038+
"textR": 0
10721039
},
1073-
"parameters": [
1074-
"Object",
1075-
"Behavior",
1076-
""
1077-
]
1040+
"comment": "Use a small margin is used to avoid to flicker between 2 directions."
10781041
},
10791042
{
1080-
"type": {
1081-
"value": "AnimatableCapability::AnimatableBehavior::SetElapsedTime"
1082-
},
1083-
"parameters": [
1084-
"Object",
1085-
"Animation",
1086-
"=",
1087-
"AnimationElapsedTime"
1043+
"type": "BuiltinCommonInstructions::Standard",
1044+
"conditions": [
1045+
{
1046+
"type": {
1047+
"value": "BuiltinCommonInstructions::CompareNumbers"
1048+
},
1049+
"parameters": [
1050+
"abs(Object.Behavior::DirectionDifference(NewAnimationDirection, AnimationDirection))",
1051+
">",
1052+
"0.5 + 0.03125"
1053+
]
1054+
}
1055+
],
1056+
"actions": [],
1057+
"events": [
1058+
{
1059+
"type": "BuiltinCommonInstructions::Standard",
1060+
"conditions": [],
1061+
"actions": [
1062+
{
1063+
"type": {
1064+
"value": "SetNumberVariable"
1065+
},
1066+
"parameters": [
1067+
"AnimationDirection",
1068+
"=",
1069+
"mod(mod(round(NewAnimationDirection), DirectionCount) + DirectionCount, DirectionCount)"
1070+
]
1071+
},
1072+
{
1073+
"type": {
1074+
"value": "SetNumberVariable"
1075+
},
1076+
"parameters": [
1077+
"AnimationElapsedTime",
1078+
"=",
1079+
"Object.Animation::ElapsedTime()"
1080+
]
1081+
},
1082+
{
1083+
"type": {
1084+
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationName"
1085+
},
1086+
"parameters": [
1087+
"Object",
1088+
"Behavior",
1089+
""
1090+
]
1091+
},
1092+
{
1093+
"type": {
1094+
"value": "AnimatableCapability::AnimatableBehavior::SetElapsedTime"
1095+
},
1096+
"parameters": [
1097+
"Object",
1098+
"Animation",
1099+
"=",
1100+
"AnimationElapsedTime"
1101+
]
1102+
}
1103+
],
1104+
"variables": [
1105+
{
1106+
"folded": true,
1107+
"name": "AnimationElapsedTime",
1108+
"type": "number",
1109+
"value": 0
1110+
}
1111+
]
1112+
}
10881113
]
10891114
}
10901115
],
10911116
"variables": [
10921117
{
10931118
"folded": true,
1094-
"name": "AnimationElapsedTime",
1119+
"name": "NewAnimationDirection",
10951120
"type": "number",
10961121
"value": 0
10971122
}
@@ -1109,11 +1134,6 @@
11091134
"name": "Behavior",
11101135
"supplementaryInformation": "TopDownMovementAnimator::TopDownMovementAnimator",
11111136
"type": "behavior"
1112-
},
1113-
{
1114-
"description": "Direction",
1115-
"name": "NewDirection",
1116-
"type": "expression"
11171137
}
11181138
],
11191139
"objectGroups": []

0 commit comments

Comments
 (0)