Skip to content

Commit 9b7fe3c

Browse files
committed
Air-Maneuver Actuates on Button Up
Updated the maneuver system so the character is launched with an air maneuver if the character actuates the maneuver a second time (button up) during their ascent. This system needs refinement as NPC character will have to actuate manuver twice to simulate button Up & Down to do consecutive jumps.
1 parent 7c05087 commit 9b7fe3c

File tree

8 files changed

+54
-26
lines changed

8 files changed

+54
-26
lines changed
0 Bytes
Binary file not shown.
32 KB
Binary file not shown.
3.94 MB
Binary file not shown.

Ranma Game/Assets/Character.controller

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,25 +280,25 @@ AnimatorController:
280280
m_DefaultFloat: 0
281281
m_DefaultInt: 0
282282
m_DefaultBool: 0
283-
m_Controller: {fileID: 0}
283+
m_Controller: {fileID: 9100000}
284284
- m_Name: Damage
285285
m_Type: 1
286286
m_DefaultFloat: 0
287287
m_DefaultInt: 0
288288
m_DefaultBool: 0
289-
m_Controller: {fileID: 0}
289+
m_Controller: {fileID: 9100000}
290290
- m_Name: ChargedAttack
291291
m_Type: 4
292292
m_DefaultFloat: 0
293293
m_DefaultInt: 0
294294
m_DefaultBool: 0
295-
m_Controller: {fileID: 0}
295+
m_Controller: {fileID: 9100000}
296296
- m_Name: MoveSpeedPenaltyPercentage
297297
m_Type: 1
298298
m_DefaultFloat: 0
299299
m_DefaultInt: 0
300300
m_DefaultBool: 0
301-
m_Controller: {fileID: 0}
301+
m_Controller: {fileID: 9100000}
302302
m_AnimatorLayers:
303303
- serializedVersion: 5
304304
m_Name: Base Layer
@@ -348,9 +348,9 @@ AnimatorStateTransition:
348348
m_PrefabAsset: {fileID: 0}
349349
m_Name:
350350
m_Conditions:
351-
- m_ConditionMode: 6
351+
- m_ConditionMode: 7
352352
m_ConditionEvent: AttackType
353-
m_EventTreshold: 0
353+
m_EventTreshold: 1
354354
m_DstStateMachine: {fileID: 0}
355355
m_DstState: {fileID: 477146616253968979}
356356
m_Solo: 0

Ranma Game/Assets/Scripts/Character/Character.cs

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,54 @@ public abstract class Character : MonoBehaviour
2323
/// <param name="moveDir"></param>
2424
protected void MoveAndRotate(Vector3 moveDir)
2525
{
26-
if (!groundedCheck.IsGrounded || _knockbackRequest.doingRequest) return;
27-
_moving = !animManager.DoingAttack;
28-
if (!_moving) _moving = animManager.InAttkComboAndCanMove;
26+
if (_knockbackRequest.doingRequest) return;
27+
28+
// Update if can move in current animation state.
29+
_moving = !animManager.DoingAttack || animManager.InAttkComboAndCanMove;
2930

30-
var (rotationDir, speed) = GetMoveAndRotate(moveDir);
31+
// Get updated rotation and speed based on requested direction.
32+
var (rotationDir, speed) = GetRotationAndSpeed(moveDir);
33+
ApplyRotation(rotationDir);
34+
35+
if (!groundedCheck.IsGrounded)
36+
{
37+
_speed = 0;
38+
return;
39+
}
3140

3241
if (animManager.InAttkComboAndCanMove)
3342
_speed = speed * animManager.AnimMoveSpeedPenalty;
3443
else
3544
_speed = speed;
36-
37-
ApplyRotation(rotationDir);
3845
}
3946

4047
/// <summary>
4148
/// Request maneuver start.
4249
/// </summary>
4350
protected void Maneuver()
4451
{
52+
// Stop attack animations when maneuver.
4553
animManager.SetCancelChargedAttack();
46-
if (groundedCheck.IsGrounded) _doingAirManeuver = false;
4754

48-
if (!groundedCheck.IsGrounded && !_doingJump && !_doingAirManeuver)
55+
// Do mid-air maneuver if register jump again while ascending up in the air.
56+
if (!groundedCheck.IsGrounded && !_doingAirManeuver && !doJumpToggle && rb.velocity.y >= 0)
4957
InAirManeuver();
5058

51-
_doingJump = true;
59+
// If normal jump.
60+
if (doJumpToggle)
61+
{
62+
_doingJump = true;
63+
}
64+
65+
// Flip toggle.
66+
doJumpToggle = !doJumpToggle;
5267
}
5368

69+
private bool doJumpToggle = true;
70+
5471
private void InAirManeuver()
5572
{
73+
Debug.Log("CALLED");
5674
animManager.SetCancelChargedAttack();
5775
_doingAirManeuver = true;
5876
var target = transform.forward * 10 + transform.up * 5;
@@ -67,7 +85,6 @@ private void InAirManeuver()
6785
protected void ManeuverEnd()
6886
{
6987
animManager.SetCancelChargedAttack();
70-
_doingJump = false;
7188
}
7289

7390
private bool _doingJump = false;
@@ -104,7 +121,7 @@ protected void Interact()
104121
/// Move character and rotate to move direction.
105122
/// </summary>
106123
/// <param name="moveDirRequest"></param>
107-
private (Vector3 rotationDir, float speed) GetMoveAndRotate(Vector2 moveDirRequest)
124+
private (Vector3 rotationDir, float speed) GetRotationAndSpeed(Vector2 moveDirRequest)
108125
{
109126
// No moving or rotation during attacks or not moving.
110127
if (!_moving || moveDirRequest == Vector2.zero)
@@ -194,6 +211,12 @@ private void HandleMovingAndJump()
194211
bool IsGrounded = groundedCheck.IsGrounded;
195212
var (newKnockbackRequest, _, _, doingKnockback) = _knockbackRequest;
196213

214+
// Set not air-maneuvering if grounded.
215+
if (groundedCheck.IsGrounded)
216+
{
217+
_doingAirManeuver = false;
218+
}
219+
197220
// If trying to move & able to.
198221
if (_moving && !newKnockbackRequest && IsGrounded && !doingKnockback)
199222
{
@@ -234,6 +257,12 @@ private void FixedUpdate()
234257
HandleKnockback();
235258

236259
HandleMovingAndJump();
260+
261+
// Stop manuever after landing again.
262+
if ((_doingJump || _doingAirManeuver) && groundedCheck.IsGrounded)
263+
{
264+
// ManeuverEnd();
265+
}
237266
}
238267

239268
/// <summary>

Ranma Game/Assets/Scripts/Character/PlayerChar.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,28 @@ public class PlayerChar : Character
66
{
77
private PlayerControls controls;
88
private Vector2 moveDir = Vector2.zero;
9+
910
private void Awake()
1011
{
1112
rb = GetComponent<Rigidbody>();
1213
animManager = GetComponent<CharacterAnimManager>();
1314
groundedCheck = GetComponent<GroundedCheck>();
1415

1516
controls = new PlayerControls();
16-
17-
1817
}
1918

2019
private void Update()
2120
{
2221
// Don't move if attacking.
23-
MoveAndRotate(moveDir);
22+
MoveAndRotate(moveDir);
2423
}
2524

2625
private void OnEnable()
2726
{
2827
controls.Gameplay.Enable();
2928

30-
controls.Gameplay.Maneuver.started += ctx => Maneuver();
31-
controls.Gameplay.Maneuver.performed += ctx => ManeuverEnd();
29+
controls.Gameplay.Maneuver.performed += ctx => Maneuver();
30+
// controls.Gameplay.Maneuver.performed += ctx => ManeuverEnd();
3231
controls.Gameplay.AttackStd.performed += ctx => AttackStd();
3332
controls.Gameplay.AttackHeavy.performed += ctx => AttackHeavy();
3433
controls.Gameplay.Interact.performed += ctx => Interact();
@@ -40,5 +39,5 @@ private void OnEnable()
4039
private void OnDisable()
4140
{
4241
controls.Gameplay.Disable();
43-
}
44-
}
42+
}
43+
}

Ranma Game/Assets/Scripts/Input Controls/PlayerControls.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public @PlayerControls()
4848
""id"": ""ff53ebcb-5a75-4308-bef4-325c08e9e9e8"",
4949
""expectedControlType"": """",
5050
""processors"": """",
51-
""interactions"": """"
51+
""interactions"": ""Press,Press(behavior=1)""
5252
},
5353
{
5454
""name"": ""Interact"",

Ranma Game/Assets/Scripts/Input Controls/PlayerControls.inputactions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"id": "ff53ebcb-5a75-4308-bef4-325c08e9e9e8",
3636
"expectedControlType": "",
3737
"processors": "",
38-
"interactions": ""
38+
"interactions": "Press,Press(behavior=1)"
3939
},
4040
{
4141
"name": "Interact",

0 commit comments

Comments
 (0)