lockon, targetting and rolls control improvements
This commit is contained in:
@@ -31,6 +31,16 @@ namespace Beyond
|
||||
[Tooltip("The name of the animation state to play when rolling right while strafing.")]
|
||||
public string strafeRollRightAnim = "Roll_Right";
|
||||
|
||||
// --- UPDATED FIELDS FOR INDEPENDENT CONTROL ---
|
||||
[Header("Beyond's Strafe Roll Correction")]
|
||||
[Tooltip("The fixed angle to rotate the character before a LEFT strafe roll.")]
|
||||
[Range(0f, 90f)]
|
||||
public float strafeRollLeftCorrectionAngle = 45f;
|
||||
|
||||
[Tooltip("The fixed angle to rotate the character before a RIGHT strafe roll.")]
|
||||
[Range(0f, 90f)]
|
||||
public float strafeRollRightCorrectionAngle = 70f;
|
||||
// --- END OF UPDATED FIELDS ---
|
||||
|
||||
public bool GodMode
|
||||
{
|
||||
@@ -51,7 +61,7 @@ namespace Beyond
|
||||
{
|
||||
base.Start();
|
||||
}
|
||||
|
||||
|
||||
protected override void RollBehavior()
|
||||
{
|
||||
// If we are not strafing, use the default Invector roll behavior.
|
||||
@@ -61,17 +71,15 @@ namespace Beyond
|
||||
return;
|
||||
}
|
||||
|
||||
// --- Custom Strafe Roll with Root Motion ---
|
||||
// Custom Strafe Roll with Root Motion (no rotation logic needed here anymore)
|
||||
if (!isRolling)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// We apply the root motion position change directly.
|
||||
Vector3 deltaPosition = new Vector3(animator.deltaPosition.x, 0f, animator.deltaPosition.z);
|
||||
Vector3 v = (deltaPosition / Time.deltaTime) * (1f - stopMoveWeight);
|
||||
|
||||
// Apply gravity to the roll if enabled
|
||||
if (rollUseGravity && animator.GetNormalizedTime(baseLayer) >= rollUseGravityTime)
|
||||
{
|
||||
v.y = _rigidbody.linearVelocity.y;
|
||||
@@ -82,12 +90,11 @@ namespace Beyond
|
||||
|
||||
public override void Roll()
|
||||
{
|
||||
// If we are strafing, use our custom directional logic.
|
||||
if (isStrafing)
|
||||
{
|
||||
TriggerStrafeRoll(strafeRollForwardAnim, strafeRollBackwardAnim, strafeRollLeftAnim, strafeRollRightAnim);
|
||||
}
|
||||
else // Otherwise, use the default free-locomotion roll.
|
||||
else
|
||||
{
|
||||
OnRoll.Invoke();
|
||||
isRolling = true;
|
||||
@@ -99,7 +106,6 @@ namespace Beyond
|
||||
|
||||
public virtual void Dash()
|
||||
{
|
||||
// The Dash logic now mirrors the Roll logic.
|
||||
if (isStrafing)
|
||||
{
|
||||
TriggerStrafeRoll(strafeRollForwardAnim, strafeRollBackwardAnim, strafeRollLeftAnim, strafeRollRightAnim);
|
||||
@@ -114,7 +120,7 @@ namespace Beyond
|
||||
}
|
||||
}
|
||||
|
||||
// This is the private helper method that contains the core logic for this feature.
|
||||
// --- MODIFIED METHOD WITH TWO-ANGLE LOGIC ---
|
||||
private void TriggerStrafeRoll(string forwardAnim, string backwardAnim, string leftAnim, string rightAnim)
|
||||
{
|
||||
OnRoll.Invoke();
|
||||
@@ -127,10 +133,30 @@ namespace Beyond
|
||||
// Prioritize side rolls based on horizontal input.
|
||||
if (Mathf.Abs(horizontalSpeed) > strafeRollInputThreshold)
|
||||
{
|
||||
animToPlay = horizontalSpeed > 0 ? rightAnim : leftAnim;
|
||||
float correction = 0f;
|
||||
|
||||
// Check if rolling right (positive horizontal speed)
|
||||
if (horizontalSpeed > 0)
|
||||
{
|
||||
animToPlay = rightAnim;
|
||||
// For a right roll, we apply a negative rotation (turn left) to angle the trajectory forward.
|
||||
correction = -strafeRollRightCorrectionAngle;
|
||||
}
|
||||
// Otherwise, rolling left
|
||||
else
|
||||
{
|
||||
animToPlay = leftAnim;
|
||||
// For a left roll, we apply a positive rotation (turn right) to angle the trajectory forward.
|
||||
correction = strafeRollLeftCorrectionAngle;
|
||||
}
|
||||
|
||||
// Apply the calculated rotation instantly around the Y-axis.
|
||||
if (correction != 0)
|
||||
{
|
||||
transform.Rotate(0, correction, 0);
|
||||
}
|
||||
}
|
||||
// If horizontal input is not met, always default to the backward roll.
|
||||
// This effectively blocks the forward roll.
|
||||
// If horizontal input is not met, default to the backward roll.
|
||||
else
|
||||
{
|
||||
animToPlay = backwardAnim;
|
||||
@@ -138,6 +164,7 @@ namespace Beyond
|
||||
|
||||
animator.CrossFadeInFixedTime(animToPlay, rollTransition, baseLayer);
|
||||
}
|
||||
// --- END OF MODIFIED METHOD ---
|
||||
|
||||
public void OnEvadeStart() { if (!m_GodMode) isImmortal = true; }
|
||||
public void OnEvadeEnd() { if (!m_GodMode) isImmortal = false; }
|
||||
|
||||
Reference in New Issue
Block a user