dash v2 WIP, prefab corrections, changes for build

This commit is contained in:
2026-01-23 15:14:41 +01:00
parent 916dae1183
commit 0e0262f22d
16 changed files with 1952 additions and 2575 deletions

View File

@@ -10669,12 +10669,6 @@ MonoBehaviour:
destinationDialogueID: 3
isConnector: 0
priority: 2
- originConversationID: 20
originDialogueID: 1
destinationConversationID: 20
destinationDialogueID: 8
isConnector: 0
priority: 2
- originConversationID: 20
originDialogueID: 1
destinationConversationID: 20
@@ -10699,6 +10693,12 @@ MonoBehaviour:
destinationDialogueID: 12
isConnector: 0
priority: 2
- originConversationID: 20
originDialogueID: 1
destinationConversationID: 20
destinationDialogueID: 8
isConnector: 0
priority: 2
conditionsString:
userScript:
onExecute:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cfbc6a970e156444390379ba06b74bde
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -60733,13 +60733,7 @@ MonoBehaviour:
m_ignoreTriggers: 1
healthRecoveryCap: 1
useAnimationBasedRotation: 0
strafeRollForwardAnim: Roll_Forward
strafeRollBackwardAnim: Roll_Backward
strafeRollLeftAnim: Roll_Left
strafeRollRightAnim: Roll_Right
strafeRollLeftCorrectionAngle: -20
strafeRollRightCorrectionAngle: -10
strafeRollBackwardCorrectionAngle: 180
dashBlendTreeState: Dash_Directional
--- !u!114 &9202663235077955828
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@@ -949,6 +949,28 @@ AnimatorTransition:
m_Mute: 0
m_IsExit: 1
serializedVersion: 1
--- !u!1101 &-7459024323335296994
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 0}
m_Solo: 0
m_Mute: 0
m_IsExit: 1
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.6394231
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-7444852651264506119
AnimatorStateTransition:
m_ObjectHideFlags: 1
@@ -40885,7 +40907,10 @@ AnimatorStateMachine:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Actions
m_ChildStates: []
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 7107860863601028181}
m_Position: {x: 529.07166, y: -184.21014, z: 0}
m_ChildStateMachines:
- serializedVersion: 1
m_StateMachine: {fileID: 1107386280914322628}
@@ -44748,7 +44773,7 @@ AnimatorState:
m_TimeParameterActive: 0
m_Motion: {fileID: 7400024, guid: c5937c944a220444aa33be3fe1480174, type: 3}
m_Tag:
m_SpeedParameter: Direction
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
@@ -46808,6 +46833,66 @@ AnimatorStateTransition:
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!206 &4160547945503330080
BlendTree:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Blend Tree
m_Childs:
- serializedVersion: 2
m_Motion: {fileID: 1827226128182048838, guid: 10c005d4a1cfe8648af9ff7bfc4f7275,
type: 3}
m_Threshold: 0
m_Position: {x: 0, y: 0}
m_TimeScale: 1
m_CycleOffset: 0
m_DirectBlendParameter: InputHorizontal
m_Mirror: 0
- serializedVersion: 2
m_Motion: {fileID: 1827226128182048838, guid: 10c005d4a1cfe8648af9ff7bfc4f7275,
type: 3}
m_Threshold: 0.25
m_Position: {x: 0, y: -1}
m_TimeScale: 1
m_CycleOffset: 0
m_DirectBlendParameter: InputHorizontal
m_Mirror: 0
- serializedVersion: 2
m_Motion: {fileID: 1827226128182048838, guid: 0e637c252c2643d4d9770ad55b6e71c1,
type: 3}
m_Threshold: 0.5
m_Position: {x: 0, y: 1}
m_TimeScale: 1
m_CycleOffset: 0
m_DirectBlendParameter: InputHorizontal
m_Mirror: 0
- serializedVersion: 2
m_Motion: {fileID: 1827226128182048838, guid: 91b0987685baf44bb853583ed38ef4ed,
type: 3}
m_Threshold: 0.75
m_Position: {x: -1, y: 0}
m_TimeScale: 1
m_CycleOffset: 0
m_DirectBlendParameter: InputHorizontal
m_Mirror: 0
- serializedVersion: 2
m_Motion: {fileID: 1827226128182048838, guid: 1c9f48ddca32d45479d6aeb95df77d7f,
type: 3}
m_Threshold: 1
m_Position: {x: 1, y: 0}
m_TimeScale: 1
m_CycleOffset: 0
m_DirectBlendParameter: InputHorizontal
m_Mirror: 0
m_BlendParameter: InputHorizontal
m_BlendParameterY: InputVertical
m_MinThreshold: 0
m_MaxThreshold: 1
m_UseAutomaticThresholds: 1
m_NormalizedBlendValues: 0
m_BlendType: 3
--- !u!114 &4236067981039347910
MonoBehaviour:
m_ObjectHideFlags: 1
@@ -48639,6 +48724,33 @@ AnimatorStateTransition:
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &7107860863601028181
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Dash_Directional
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: -7459024323335296994}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 4160547945503330080}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &7110115907626490810
AnimatorStateTransition:
m_ObjectHideFlags: 1

View File

@@ -12,5 +12,5 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e7af411c873524f6ba73fa8f5aa07217, type: 3}
m_Name: Build
m_EditorClassIdentifier:
version: 2906
version:
path: '/Users/marcin/projects/beYond '

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -23,7 +23,7 @@ MonoBehaviour:
LoadSceneMode: 0
- LevelName: Wasteland_Arenas
LevelNameToDisplay: Wasteland
DialogueVariableName:
DialogueVariableName: WastelandTravelUnlocked
LoadSceneMode: 0
- LevelName: Ruined_Town
LevelNameToDisplay: Ruined Town

View File

@@ -14,36 +14,16 @@ namespace Beyond
public bool m_ignoreTriggers = true;
[Header("Beyond Health Logic")]
// Default cap is 1.0 (100% HP)
public float healthRecoveryCap = 1f;
[Header("Beyond's Custom Settings")]
[Tooltip("When 'Use RootMotion' is checked, and this is true, the animation's root motion will control character rotation (for 8-way directional movement). If false, the script will rotate the character to face the input direction.")]
public bool useAnimationBasedRotation = false;
[Header("Beyond's Strafe Combat Settings")]
[Tooltip("The name of the animation state to play when rolling forward while strafing. (This is now disabled)")]
public string strafeRollForwardAnim = "Roll_Forward"; // Kept for reference, but won't be used
[Tooltip("The name of the animation state to play when rolling backward while strafing.")]
public string strafeRollBackwardAnim = "Roll_Backward";
[Tooltip("The name of the animation state to play when rolling left while strafing.")]
public string strafeRollLeftAnim = "Roll_Left";
[Tooltip("The name of the animation state to play when rolling right while strafing.")]
public string strafeRollRightAnim = "Roll_Right";
[Header("Beyond's Dash Settings")]
public string dashBlendTreeState = "Dash_Directional";
// --- UPDATED FIELDS FOR FINER CONTROL ---
[Header("Beyond's Strafe Roll Correction")]
[Tooltip("An additional angle to apply for a LEFT strafe roll.")]
[Range(-90f, 90f)]
public float strafeRollLeftCorrectionAngle = -45f;
[Tooltip("An additional angle to apply for a RIGHT strafe roll.")]
[Range(-90f, 90f)]
public float strafeRollRightCorrectionAngle = 45f;
[Tooltip("An additional angle to apply for a BACKWARD strafe roll. Use 0 for a standard 180-degree roll.")]
[Range(-180f, 180f)]
public float strafeRollBackwardCorrectionAngle = 0f;
// --- END OF UPDATED FIELDS ---
// Internal flag to lock animator parameters during dash
private bool _lockAnimParamsForDash = false;
public bool GodMode
{
@@ -59,10 +39,7 @@ namespace Beyond
{
get
{
// Calculate the actual HP limit based on the cap
float limitHP = maxHealth * healthRecoveryCap;
// Add the check: currentHealth must be LESS than the Limit
return base.canRecoverHealth && (_currentHealth < limitHP);
}
}
@@ -79,124 +56,86 @@ namespace Beyond
protected override void RollBehavior()
{
if (!isStrafing)
{
base.RollBehavior();
return;
}
if (!isRolling)
{
return;
}
Vector3 deltaPosition = new Vector3(animator.deltaPosition.x, 0f, animator.deltaPosition.z);
Vector3 v = (deltaPosition / Time.deltaTime) * (1f - stopMoveWeight);
if (rollUseGravity && animator.GetNormalizedTime(baseLayer) >= rollUseGravityTime)
{
v.y = _rigidbody.linearVelocity.y;
}
_rigidbody.linearVelocity = v;
base.RollBehavior();
}
public override void Roll()
{
if (isStrafing)
{
TriggerStrafeRoll(strafeRollForwardAnim, strafeRollBackwardAnim, strafeRollLeftAnim, strafeRollRightAnim);
}
else
{
OnRoll.Invoke();
isRolling = true;
animator.CrossFadeInFixedTime("Roll", rollTransition, baseLayer);
ReduceStamina(rollStamina, false);
currentStaminaRecoveryDelay = 2f;
}
Dash();
}
public virtual void Dash()
{
if (isStrafing)
{
TriggerStrafeRoll(strafeRollForwardAnim, strafeRollBackwardAnim, strafeRollLeftAnim, strafeRollRightAnim);
}
else
{
OnRoll.Invoke();
isRolling = true;
animator.CrossFadeInFixedTime("Dash", rollTransition, baseLayer);
ReduceStamina(rollStamina, false);
currentStaminaRecoveryDelay = 2f;
}
}
// --- FINAL ROBUST METHOD ---
// This logic now handles all specified cases:
// 1. Sets a base rotation facing the camera to ensure consistency.
// 2. Defaults to a backward roll if input is near-zero (fixing the lingering roll issue).
// 3. Never uses the forward roll; it triggers a backward roll instead.
// 4. Applies a unique correction angle for backward rolls as well as side rolls.
private void TriggerStrafeRoll(string forwardAnim, string backwardAnim, string leftAnim, string rightAnim)
{
OnRoll.Invoke();
isRolling = true;
ReduceStamina(rollStamina, false);
currentStaminaRecoveryDelay = 2f;
string animToPlay;
float correctionAngle = 0f;
// Determine the base "forward" direction from the camera, ignoring vertical tilt.
Vector3 baseForward = Vector3.Scale(Camera.main.transform.forward, new Vector3(1, 0, 1)).normalized;
if (baseForward == Vector3.zero) baseForward = transform.forward; // Fallback
// Set the character's rotation to this base direction. This provides a clean slate.
transform.rotation = Quaternion.LookRotation(baseForward);
// Check if input is negligible (joystick is centered).
// input.sqrMagnitude is more efficient than input.magnitude. 0.1*0.1=0.01.
if (input.sqrMagnitude < 0.01f)
// 1. Handle Stationary (Backwards Dash)
if (input.sqrMagnitude < 0.05f)
{
// If no input, always perform a backward roll.
animToPlay = backwardAnim;
correctionAngle = strafeRollBackwardCorrectionAngle;
ApplyDashParams(0f, -1f);
}
else
{
// If there IS input, determine the dominant direction.
if (Mathf.Abs(verticalSpeed) >= Mathf.Abs(horizontalSpeed))
// 2. Handle Directional Input (Camera Relative -> Character Relative)
// A. Get the Input Direction relative to the Camera
Vector3 inputDir = Vector3.zero;
if (Camera.main != null)
{
// Vertical input is dominant.
// ALWAYS use the backward roll, regardless of forward or backward input.
animToPlay = backwardAnim;
correctionAngle = strafeRollBackwardCorrectionAngle;
// Convert joystick input (X,Y) into World Space based on Camera facing
Vector3 camFwd = Vector3.Scale(Camera.main.transform.forward, new Vector3(1, 0, 1)).normalized;
Vector3 camRight = Vector3.Scale(Camera.main.transform.right, new Vector3(1, 0, 1)).normalized;
inputDir = (camFwd * input.y + camRight * input.x).normalized;
}
else
{
// Horizontal input is dominant.
if (horizontalSpeed > 0)
{
animToPlay = rightAnim;
correctionAngle = strafeRollRightCorrectionAngle;
}
else
{
animToPlay = leftAnim;
correctionAngle = strafeRollLeftCorrectionAngle;
}
// Fallback if no camera found
inputDir = new Vector3(input.x, 0, input.y).normalized;
}
}
// Apply the chosen correction angle if it's not zero.
if (correctionAngle != 0f)
{
transform.Rotate(0, correctionAngle, 0);
}
// Play the selected animation.
animator.CrossFadeInFixedTime(animToPlay, rollTransition, baseLayer);
}
// --- END OF FINAL METHOD ---
// B. Convert that World Direction into the Character's Local Space
// This tells us: "Is the input to the Left, Right, or Forward of ME?"
Vector3 localDir = transform.InverseTransformDirection(inputDir);
// C. Send to Animator
ApplyDashParams(localDir.x, localDir.z);
}
// 3. Play Animation
animator.CrossFadeInFixedTime(dashBlendTreeState, rollTransition, baseLayer);
// 4. Lock parameters briefly so Invector doesn't overwrite them immediately
StartCoroutine(LockDashParamsRoutine());
}
// Helper to set params and lock the update loop
private void ApplyDashParams(float x, float y)
{
_lockAnimParamsForDash = true;
animator.SetFloat(vAnimatorParameters.InputHorizontal, x);
animator.SetFloat(vAnimatorParameters.InputVertical, y);
}
// Release the lock after a short delay (once the blend has firmly started)
private IEnumerator LockDashParamsRoutine()
{
yield return new WaitForSeconds(0.2f); // Adjust this if the blend pops back too soon
_lockAnimParamsForDash = false;
}
// --- CRITICAL FIX: Override Invector's Parameter Update ---
public override void UpdateAnimatorParameters()
{
// If we are locking parameters for the dash, DO NOT let the base class overwrite them.
if (_lockAnimParamsForDash) return;
// Otherwise, run standard Invector logic
base.UpdateAnimatorParameters();
}
// Standard overrides below...
public void OnEvadeStart() { if (!m_GodMode) isImmortal = true; }
public void OnEvadeEnd() { if (!m_GodMode) isImmortal = false; }
public override void ActionsControl() { base.ActionsControl(); m_isDashing = IsAnimatorTag("IsDashing"); }
@@ -286,40 +225,5 @@ namespace Beyond
if (isStrafing || !useAnimationBasedRotation) RotateToDirection(dir);
}
}
public override void UpdateAnimatorParameters()
{
if (disableAnimations) return;
animator.SetBool(vAnimatorParameters.IsStrafing, isStrafing);
animator.SetBool(vAnimatorParameters.IsSprinting, isSprinting);
animator.SetBool(vAnimatorParameters.IsSliding, isSliding && !isRolling);
animator.SetBool(vAnimatorParameters.IsCrouching, isCrouching);
animator.SetBool(vAnimatorParameters.IsGrounded, isGrounded);
animator.SetBool(vAnimatorParameters.IsDead, isDead);
animator.SetFloat(vAnimatorParameters.GroundDistance, groundDistance);
animator.SetFloat(vAnimatorParameters.GroundAngle, GroundAngleFromDirection());
if (!isGrounded) animator.SetFloat(vAnimatorParameters.VerticalVelocity, verticalVelocity);
{
if (isStrafing)
{
animator.SetFloat(vAnimatorParameters.InputHorizontal, horizontalSpeed, strafeSpeed.animationSmooth, Time.fixedDeltaTime);
animator.SetFloat(vAnimatorParameters.InputVertical, verticalSpeed, strafeSpeed.animationSmooth, Time.fixedDeltaTime);
}
else
{
animator.SetFloat(vAnimatorParameters.InputVertical, verticalSpeed, freeSpeed.animationSmooth, Time.fixedDeltaTime);
animator.SetFloat(vAnimatorParameters.InputHorizontal, useAnimationBasedRotation ? horizontalSpeed : 0, freeSpeed.animationSmooth, Time.fixedDeltaTime);
}
animator.SetFloat(vAnimatorParameters.InputMagnitude, Mathf.LerpUnclamped(inputMagnitude, 0f, stopMoveWeight), isStrafing ? strafeSpeed.animationSmooth : freeSpeed.animationSmooth, Time.fixedDeltaTime);
if (useLeanMovementAnim && inputMagnitude >= 0.1f)
{
animator.SetFloat(vAnimatorParameters.RotationMagnitude, rotationMagnitude, leanSmooth, Time.fixedDeltaTime);
}
else if (useTurnOnSpotAnim && inputMagnitude < 0.1f)
{
animator.SetFloat(vAnimatorParameters.RotationMagnitude, (float)System.Math.Round(rotationMagnitude, 2), rotationMagnitude == 0 ? 0.1f : 0.01f, Time.fixedDeltaTime);
}
}
}
}
}

View File

@@ -56,7 +56,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Normals:
m_Texture: {fileID: 2800000, guid: bde6cb2e213a1a84a9a579bfd2ac765e, type: 3}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:

View File

@@ -65,7 +65,7 @@ Material:
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BlendOp: 2
- _BlendOp: 0
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
@@ -79,7 +79,7 @@ Material:
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlend: 5
- _UVSec: 0
- _ZWrite: 1
m_Colors:

View File

@@ -117,6 +117,7 @@ Material:
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _DstBlendAlpha: 10
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
@@ -131,6 +132,7 @@ Material:
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 1
- _UVSec: 0
- _ZTest: 8

View File

@@ -117,6 +117,7 @@ Material:
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _DstBlendAlpha: 10
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
@@ -131,6 +132,7 @@ Material:
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 5
- _SrcBlendAlpha: 1
- _Surface: 1
- _UVSec: 0
- _ZTest: 8

View File

@@ -118,6 +118,7 @@ Material:
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _DstBlendAlpha: 10
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
@@ -132,6 +133,7 @@ Material:
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 1
- _UVSec: 0
- _ZTest: 8

View File

@@ -172,7 +172,7 @@ PlayerSettings:
buildNumber:
Standalone: 0
VisionOS: 0
iPhone: 2906
iPhone:
tvOS: 0
overrideDefaultApplicationIdentifier: 1
AndroidBundleVersionCode: 1