2026-05-21 이동사격 구현
This commit is contained in:
BIN
Assets/01_Scenes/GameScene.unity
LFS
BIN
Assets/01_Scenes/GameScene.unity
LFS
Binary file not shown.
@@ -45,6 +45,7 @@ public class WeaponData : ScriptableObject
|
||||
[Header("Equipped Animations")]
|
||||
public string IdleAnimationState; // 장착 시 idle 애니메이션 (예: "Idle_Sword")
|
||||
public string WalkAnimationState; // 장착 시 walk 애니메이션 (예: "Walk_Sword")
|
||||
public string BackpedalAnimationState; // 장착 시 백페달 애니메이션 (Down+좌우, 비우면 PlayerController 기본값)
|
||||
|
||||
[Header("Attack")]
|
||||
public ComboNode AttackRootNode; // Punch 입력 시 사용할 콤보 root (단일 노드 가능)
|
||||
|
||||
@@ -20,6 +20,8 @@ public class PlayerController : MonoBehaviour,IDamageable
|
||||
[Header("Movement")]
|
||||
[SerializeField] private float _moveSpeed = 5f; // 이동 속도 (units/sec)
|
||||
[SerializeField] private string _walkAnimationState = "Run"; // 걷기/달리기 애니메이션 State 이름
|
||||
[SerializeField] private float _backpedalSpeed = 3f; // 백페달(Down+좌우) 이동 속도 — 보통 _moveSpeed보다 느리게
|
||||
[SerializeField] private string _backpedalAnimationState = "BackWalk"; // 백페달 시 재생할 애니메이션 (뒤로 걷기)
|
||||
private float _moveInputX = 0f; // 현재 X 입력값 (-1/0/1)
|
||||
private float _moveInputY = 0f; // 현재 Y 입력값 (-1/0/1) — 위/아래 방향 공격 판정용
|
||||
private string _activeBaseState; // 현재 재생 중인 locomotion State (중복 Play 방지용)
|
||||
@@ -252,7 +254,11 @@ private void FixedUpdate()
|
||||
|
||||
// 입력 잠금이 없고, (액션 중이 아니거나 액션이 이동을 허용할 때) 좌우 입력으로 velocity 갱신.
|
||||
if (!IsMovementLocked() && (!IsActionActive() || _actionAllowsMovement))
|
||||
_rb.linearVelocity = new Vector2(_moveInputX * _moveSpeed, _rb.linearVelocity.y);
|
||||
{
|
||||
// 백페달이면 느린 속도. 액션 중에도 동일하게 적용 (이동사격 = Down 변형 + CanMoveDuringAction).
|
||||
float moveSpeed = IsBackpedaling() ? _backpedalSpeed : _moveSpeed;
|
||||
_rb.linearVelocity = new Vector2(_moveInputX * moveSpeed, _rb.linearVelocity.y);
|
||||
}
|
||||
|
||||
if (!IsFacingLocked() && (!IsActionActive() || _actionAllowsTurn))
|
||||
UpdateFacingFromMoveInput();
|
||||
@@ -306,12 +312,23 @@ private void OnMoveInput(Vector2 value)
|
||||
}
|
||||
|
||||
// SpriteRenderer.flipX로 좌우 반전 (transform.localScale이 아닌 이유: 자식 콜라이더 위치가 따라 뒤집히면 곤란).
|
||||
// Down(아래) 키를 누르고 있으면 페이싱을 고정 — 백페달에서 뒤로 가면서 정면을 유지하는 핵심 규칙.
|
||||
// 이 함수가 페이싱 전환의 단일 통로라, 여기만 막으면 locomotion·콤보 입력 전부에 적용된다.
|
||||
private void UpdateFacingFromMoveInput()
|
||||
{
|
||||
if (_moveInputY < 0f) return;
|
||||
|
||||
if (_moveInputX != 0f && _spriteRenderer != null)
|
||||
_spriteRenderer.flipX = _moveInputX < 0f;
|
||||
}
|
||||
|
||||
// Down + 좌우를 함께 누른 상태 = 백페달.
|
||||
// 페이싱 고정(UpdateFacingFromMoveInput) + 느린 이동(_backpedalSpeed) + 전용 애니메이션.
|
||||
private bool IsBackpedaling()
|
||||
{
|
||||
return _moveInputY < 0f && _moveInputX != 0f;
|
||||
}
|
||||
|
||||
// 점프 우선순위: 지상 점프 > 공중(2단) 점프
|
||||
private void OnJumpInput()
|
||||
{
|
||||
@@ -1067,6 +1084,13 @@ private string ChooseLocomotionState()
|
||||
string idle = equipped != null && !string.IsNullOrEmpty(equipped.IdleAnimationState)
|
||||
? equipped.IdleAnimationState
|
||||
: _idleAnimationState;
|
||||
string backpedal = equipped != null && !string.IsNullOrEmpty(equipped.BackpedalAnimationState)
|
||||
? equipped.BackpedalAnimationState
|
||||
: _backpedalAnimationState;
|
||||
|
||||
// 백페달(Down+좌우)이면 전용 애니메이션 — 뒤로 걷는 모션 (공격 중이 아닐 때만 표시).
|
||||
if (IsBackpedaling() && !string.IsNullOrEmpty(backpedal))
|
||||
return backpedal;
|
||||
|
||||
if (_moveInputX != 0f && !string.IsNullOrEmpty(walk))
|
||||
return walk;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
BIN
Assets/05_Data/Attack/GunRunFire.asset
LFS
Normal file
BIN
Assets/05_Data/Attack/GunRunFire.asset
LFS
Normal file
Binary file not shown.
8
Assets/05_Data/Attack/GunRunFire.asset.meta
Normal file
8
Assets/05_Data/Attack/GunRunFire.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7836bd26ed5ce164ea8854ffa1e452a5
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/05_Data/Attack/GunWalkFire.asset
LFS
Normal file
BIN
Assets/05_Data/Attack/GunWalkFire.asset
LFS
Normal file
Binary file not shown.
8
Assets/05_Data/Attack/GunWalkFire.asset.meta
Normal file
8
Assets/05_Data/Attack/GunWalkFire.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2652931608d3af46a79158b80dcfc22
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
BIN
Assets/05_Data/Weapon/Gun.asset
LFS
BIN
Assets/05_Data/Weapon/Gun.asset
LFS
Binary file not shown.
Binary file not shown.
8
Assets/_Recovery.meta
Normal file
8
Assets/_Recovery.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ca885ea8137440448a536a8e408352c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/_Recovery/0.unity
LFS
Normal file
BIN
Assets/_Recovery/0.unity
LFS
Normal file
Binary file not shown.
7
Assets/_Recovery/0.unity.meta
Normal file
7
Assets/_Recovery/0.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6e71f45f6a6eb047a72d095e2960e73
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user