update mutiplay
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
public class PlayerAirDashState : PlayerBaseState
|
||||
{
|
||||
private readonly int airDashHash = Animator.StringToHash("AirDash");
|
||||
private float dashDuration = 0.2f;
|
||||
private float dashDuration = 0.3f;
|
||||
private float dashTimer;
|
||||
private Vector3 dashDirection;
|
||||
|
||||
@@ -14,39 +13,31 @@ namespace OnlyScove.Scripts
|
||||
public override void Enter()
|
||||
{
|
||||
dashTimer = dashDuration;
|
||||
stateMachine.Anim.SetTrigger(airDashHash);
|
||||
stateMachine.Anim.SetTrigger("Dash");
|
||||
|
||||
// Reset vertical velocity so we don't carry falling momentum into the dash
|
||||
stateMachine.VelocityY = 0f;
|
||||
|
||||
// Determine dash direction
|
||||
Vector2 input = stateMachine.Input.MoveInput;
|
||||
// ĐÚNG: Sử dụng MoveInput đã đồng bộ
|
||||
Vector2 input = stateMachine.MoveInput;
|
||||
if (input != Vector2.zero)
|
||||
{
|
||||
dashDirection = new Vector3(input.x, 0f, input.y).normalized;
|
||||
|
||||
if (stateMachine.Cam != null)
|
||||
{
|
||||
dashDirection = stateMachine.Cam.PlanarRotation * dashDirection;
|
||||
}
|
||||
|
||||
stateMachine.transform.rotation = Quaternion.LookRotation(dashDirection);
|
||||
dashDirection = new Vector3(input.x, 0, input.y).normalized;
|
||||
dashDirection = stateMachine.NetworkedCameraRotation * dashDirection;
|
||||
}
|
||||
else
|
||||
{
|
||||
dashDirection = stateMachine.transform.forward;
|
||||
}
|
||||
dashDirection.y = 0;
|
||||
dashDirection.Normalize();
|
||||
}
|
||||
|
||||
public override void Tick(float deltaTime)
|
||||
{
|
||||
dashTimer -= deltaTime;
|
||||
|
||||
// Move horizontally, ignoring gravity for this brief moment
|
||||
stateMachine.Controller.Move(dashDirection * stateMachine.DashForce * deltaTime);
|
||||
// Sử dụng hàm Move tập trung
|
||||
stateMachine.Move(dashDirection * stateMachine.DashForce, 1.0f, deltaTime);
|
||||
|
||||
// When the air dash ends, return to falling
|
||||
if (dashTimer <= 0f)
|
||||
if (dashTimer <= 0)
|
||||
{
|
||||
stateMachine.SwitchState(new PlayerFallState(stateMachine));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user