2026-05-19 hp바 추가
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerController : MonoBehaviour
|
||||
public class PlayerController : MonoBehaviour,IDamageable
|
||||
{
|
||||
[Header("Movement")]
|
||||
[SerializeField] private float _moveSpeed = 5f;
|
||||
@@ -23,10 +23,12 @@ public class PlayerController : MonoBehaviour
|
||||
|
||||
[Header("Jump")]
|
||||
[SerializeField] private float _jumpForce = 8f;
|
||||
[SerializeField] private int _maxJumpCount = 2;
|
||||
[SerializeField] private Transform _groundCheck;
|
||||
[SerializeField] private float _groundCheckRadius = 0.1f;
|
||||
[SerializeField] private LayerMask _groundLayer;
|
||||
private bool _isGrounded;
|
||||
private int _jumpsUsed;
|
||||
|
||||
[Header("WallSlide")]
|
||||
[SerializeField] private Transform _wallCheckLeft;
|
||||
@@ -156,6 +158,10 @@ private void FixedUpdate()
|
||||
_isTouchingRightWall = Physics2D.OverlapCircle(_wallCheckRight.position, _wallCheckRadius, _groundLayer);
|
||||
_wallDirection = _isTouchingRightWall ? 1 : (_isTouchingLeftWall ? -1 : 0);
|
||||
|
||||
// 지면에 닿고 점프 중이 아니면(상승 중 아님) 점프 카운트 리셋.
|
||||
if (_isGrounded && _rb.linearVelocity.y <= 0f)
|
||||
_jumpsUsed = 0;
|
||||
|
||||
if (_attackCooldownTimer > 0f)
|
||||
_attackCooldownTimer -= Time.fixedDeltaTime;
|
||||
|
||||
@@ -217,13 +223,23 @@ private void OnJumpInput()
|
||||
{
|
||||
if (_isGrounded)
|
||||
{
|
||||
_rb.linearVelocity = new Vector2(_rb.linearVelocity.x, _jumpForce);
|
||||
PerformJump();
|
||||
}
|
||||
else if (IsTouchingWall)
|
||||
{
|
||||
_rb.linearVelocity = new Vector2(-_wallDirection * _wallJumpForce.x, _wallJumpForce.y);
|
||||
_inputLockTimer = _wallJumpInputLockDuration;
|
||||
}
|
||||
else if (_jumpsUsed < _maxJumpCount)
|
||||
{
|
||||
PerformJump();
|
||||
}
|
||||
}
|
||||
|
||||
private void PerformJump()
|
||||
{
|
||||
_rb.linearVelocity = new Vector2(_rb.linearVelocity.x, _jumpForce);
|
||||
_jumpsUsed++;
|
||||
}
|
||||
|
||||
private void OnPunchInput() => HandleComboInput(ComboInputType.Punch);
|
||||
@@ -1343,4 +1359,9 @@ private void DrawTimelineBar(ActionData data, float elapsed)
|
||||
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
|
||||
public void TakeDamage(int amount, Vector2 hitVelocity = default, string hitReactionAnimationState = null, Vector2? hitTargetPosition = null, bool correctHitTargetY = false, int hitPositionSolidMask = 0, float hitPositionCorrectionDuration = 0)
|
||||
{
|
||||
Debug.Log("플레이어 타격받음");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user