EerieVillage/Assets/Scripts/Mechanics/PlayerController.cs

321 lines
13 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Platformer.Gameplay;
using static Platformer.Core.Simulation;
using Platformer.Model;
using Platformer.Core;
using UnityEngine.InputSystem;
namespace Platformer.Mechanics
{
/// <summary>
/// This is the main class used to implement control of the player.
/// It is a superset of the AnimationController class, but is inlined to allow for any kind of customisation.
/// </summary>
public class PlayerController : KinematicObject
{
public AudioClip jumpAudio;
public AudioClip respawnAudio;
public AudioClip ouchAudio;
/// <summary>
/// Attack sound effect. 자동 발동 시 PlayerAttack.Execute가 PlayOneShot으로 재생.
/// BT7-Plan 2026-04-24 — VS 순수형 자동 발동 전환 후에도 audio hook 유지.
/// </summary>
public AudioClip attackAudio;
/// <summary>
/// Max horizontal speed of the player.
/// </summary>
public float maxSpeed = 7;
/// <summary>
/// Initial jump velocity at the start of a jump.
/// </summary>
public float jumpTakeOffSpeed = 7;
/// <summary>
/// Attack hitbox component (자동 GetComponent, 없으면 null — PlayerAttack.Execute에서 null 체크).
/// 공격은 PlayerAttackTicker가 주기적으로 Schedule<PlayerAttack>을 발화하여 실행.
/// </summary>
public AttackHitbox attackHitbox;
public JumpState jumpState = JumpState.Grounded;
private bool stopJump;
BT5-Dev #69: Down + Jump Drop-Through 입력 추가 (PD 명시 채택) PD 명시 (2026-05-08): "발판과 같이 아래가 뚫려있고 이동 가능한 영역이 있는 경우, 아래 방향키 상태로 점프하면 점프 모션과 함께 내려올 수 있도록" 표준 platformer 패턴 (Drop-Through Input): - Player가 발판(Layer 16) 위 + Down 방향키 + Jump 키 동시 입력 - = Layer 16 mask 강제 OFF (DROP_THROUGH_DURATION=0.3초) → 발판 통과 - = velocity.y = 0 (위 점프 X·gravity로 자연 낙하) - = jumpState = PrepareToJump (점프 애니메이션 발동·시각상 점프 모션) 변경 (PlayerController.cs 3영역): 1. 클래스 변수 추가: - float dropThroughTimer (Layer 16 mask 강제 OFF 지속 시간) - const float DROP_THROUGH_DURATION = 0.3f - bool dropThroughJump (본 frame Drop-Through 점프 발동 분기) 2. Update 영역: - Move Input 영역 y < -0.5 (Down) + Jump WasPressed → dropThroughTimer 활성 + dropThroughJump=true - 매 frame dropThroughTimer 감소 (Time.deltaTime) 3. UpdateContactFilterForDropThrough 영역: - isJumpingThrough 조건에 dropThroughTimer > 0 추가 - Drop-Through 활성 시 Layer 16 mask 강제 OFF 4. ComputeVelocity 영역: - jump && IsGrounded 시 dropThroughJump 분기: - dropThroughJump → velocity.y = 0 (위 점프 X) - else → velocity.y = jumpTakeOffSpeed (기존 정상 점프) 효과 (PD 의도 정합): - 일반 점프 (Jump only) = 위로 점프 (그대로) - Drop-Through (Down + Jump) = 발판 통과 + 점프 모션 + 자연 낙하 - 0.3초 후 mask 자동 복원 (다른 발판 위 정상 착지 가능) 후속 의무: - PD Refresh+Play 시각 검증 (발판 위 + Down + Jump → 통과·낙하 + 점프 애니메이션) - 정합 시 BT49~BT65 영구 폐기 + R2 + BT68 + BT69 영역 영구 채택
2026-05-07 15:26:12 +00:00
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
// Drop-Through (Down + Jump) — 발판 위에서 Down 유지 + 점프 시 발판 통과 + 점프 모션 + 자연 낙하
private float dropThroughTimer = 0f;
private const float DROP_THROUGH_DURATION = 0.3f;
private bool dropThroughJump = false;
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
// Jump Ascent — 점프 ascending·정점 영역 mask 강제 OFF 보장 (정점 jitter 차단)
private float jumpAscentTimer = 0f;
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
private const float JUMP_ASCENT_DURATION = 0.4f;
/*internal new*/ public Collider2D collider2d;
/*internal new*/ public AudioSource audioSource;
public Health health;
public bool controlEnabled = true;
bool jump;
Vector2 move;
SpriteRenderer spriteRenderer;
internal Animator animator;
readonly PlatformerModel model = Simulation.GetModel<PlatformerModel>();
private InputAction m_MoveAction;
private InputAction m_JumpAction;
// 현재 facing 방향 (마지막 이동 입력 기반, 정지 시 이전 값 유지).
// BT7-Plan 2026-04-24 — PlayerAttackTicker가 자동 발동 시 참조하므로 public 노출.
Vector2 facing = Vector2.right;
/// <summary>현재 플레이어 facing 방향. PlayerAttackTicker가 Schedule 시점에 참조.</summary>
public Vector2 Facing => facing;
public Bounds Bounds => collider2d.bounds;
/// <summary>
/// 마지막 grounded 위치 — 낙사 시 안전 복귀 영역 (PD 지시 2026-05-07).
/// </summary>
public Vector3 LastGroundedPosition { get; private set; }
void Awake()
{
health = GetComponent<Health>();
audioSource = GetComponent<AudioSource>();
collider2d = GetComponent<Collider2D>();
spriteRenderer = GetComponent<SpriteRenderer>();
if (spriteRenderer == null) spriteRenderer = GetComponentInChildren<SpriteRenderer>();
animator = GetComponent<Animator>();
if (animator == null) animator = GetComponentInChildren<Animator>();
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
// 동반 컴포넌트 자동 부착 (Inspector 부착 불요)
if (GetComponent<PlayerInvulnerabilityFlash>() == null) gameObject.AddComponent<PlayerInvulnerabilityFlash>();
if (GetComponent<Platformer.UI.ResurrectPromptUI>() == null) gameObject.AddComponent<Platformer.UI.ResurrectPromptUI>();
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
// 구 PlatformDropThrough 컴포넌트 자동 제거 (Drop-Through는 ContactFilter mask 동적 갱신으로 처리)
var oldDrop = GetComponent<PlatformDropThrough>();
if (oldDrop != null) Destroy(oldDrop);
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
// 사망 시 입력 차단 / 부활 시 입력 복원
if (health != null)
{
health.OnDeathEvent += OnHealthDeath;
health.OnResurrectEvent += OnHealthResurrect;
}
if (attackHitbox == null) attackHitbox = GetComponent<AttackHitbox>();
m_MoveAction = InputSystem.actions.FindAction("Player/Move");
m_JumpAction = InputSystem.actions.FindAction("Player/Jump");
m_MoveAction.Enable();
m_JumpAction.Enable();
LastGroundedPosition = transform.position;
}
void OnDestroy()
{
if (health != null)
{
health.OnDeathEvent -= OnHealthDeath;
health.OnResurrectEvent -= OnHealthResurrect;
}
}
void OnHealthDeath()
{
controlEnabled = false;
move = Vector2.zero;
}
void OnHealthResurrect()
{
controlEnabled = true;
}
protected override void Update()
{
if (controlEnabled)
{
BT5-Dev #69: Down + Jump Drop-Through 입력 추가 (PD 명시 채택) PD 명시 (2026-05-08): "발판과 같이 아래가 뚫려있고 이동 가능한 영역이 있는 경우, 아래 방향키 상태로 점프하면 점프 모션과 함께 내려올 수 있도록" 표준 platformer 패턴 (Drop-Through Input): - Player가 발판(Layer 16) 위 + Down 방향키 + Jump 키 동시 입력 - = Layer 16 mask 강제 OFF (DROP_THROUGH_DURATION=0.3초) → 발판 통과 - = velocity.y = 0 (위 점프 X·gravity로 자연 낙하) - = jumpState = PrepareToJump (점프 애니메이션 발동·시각상 점프 모션) 변경 (PlayerController.cs 3영역): 1. 클래스 변수 추가: - float dropThroughTimer (Layer 16 mask 강제 OFF 지속 시간) - const float DROP_THROUGH_DURATION = 0.3f - bool dropThroughJump (본 frame Drop-Through 점프 발동 분기) 2. Update 영역: - Move Input 영역 y < -0.5 (Down) + Jump WasPressed → dropThroughTimer 활성 + dropThroughJump=true - 매 frame dropThroughTimer 감소 (Time.deltaTime) 3. UpdateContactFilterForDropThrough 영역: - isJumpingThrough 조건에 dropThroughTimer > 0 추가 - Drop-Through 활성 시 Layer 16 mask 강제 OFF 4. ComputeVelocity 영역: - jump && IsGrounded 시 dropThroughJump 분기: - dropThroughJump → velocity.y = 0 (위 점프 X) - else → velocity.y = jumpTakeOffSpeed (기존 정상 점프) 효과 (PD 의도 정합): - 일반 점프 (Jump only) = 위로 점프 (그대로) - Drop-Through (Down + Jump) = 발판 통과 + 점프 모션 + 자연 낙하 - 0.3초 후 mask 자동 복원 (다른 발판 위 정상 착지 가능) 후속 의무: - PD Refresh+Play 시각 검증 (발판 위 + Down + Jump → 통과·낙하 + 점프 애니메이션) - 정합 시 BT49~BT65 영구 폐기 + R2 + BT68 + BT69 영역 영구 채택
2026-05-07 15:26:12 +00:00
Vector2 moveInput = m_MoveAction.ReadValue<Vector2>();
move.x = moveInput.x;
if (jumpState == JumpState.Grounded && m_JumpAction.WasPressedThisFrame())
BT5-Dev #69: Down + Jump Drop-Through 입력 추가 (PD 명시 채택) PD 명시 (2026-05-08): "발판과 같이 아래가 뚫려있고 이동 가능한 영역이 있는 경우, 아래 방향키 상태로 점프하면 점프 모션과 함께 내려올 수 있도록" 표준 platformer 패턴 (Drop-Through Input): - Player가 발판(Layer 16) 위 + Down 방향키 + Jump 키 동시 입력 - = Layer 16 mask 강제 OFF (DROP_THROUGH_DURATION=0.3초) → 발판 통과 - = velocity.y = 0 (위 점프 X·gravity로 자연 낙하) - = jumpState = PrepareToJump (점프 애니메이션 발동·시각상 점프 모션) 변경 (PlayerController.cs 3영역): 1. 클래스 변수 추가: - float dropThroughTimer (Layer 16 mask 강제 OFF 지속 시간) - const float DROP_THROUGH_DURATION = 0.3f - bool dropThroughJump (본 frame Drop-Through 점프 발동 분기) 2. Update 영역: - Move Input 영역 y < -0.5 (Down) + Jump WasPressed → dropThroughTimer 활성 + dropThroughJump=true - 매 frame dropThroughTimer 감소 (Time.deltaTime) 3. UpdateContactFilterForDropThrough 영역: - isJumpingThrough 조건에 dropThroughTimer > 0 추가 - Drop-Through 활성 시 Layer 16 mask 강제 OFF 4. ComputeVelocity 영역: - jump && IsGrounded 시 dropThroughJump 분기: - dropThroughJump → velocity.y = 0 (위 점프 X) - else → velocity.y = jumpTakeOffSpeed (기존 정상 점프) 효과 (PD 의도 정합): - 일반 점프 (Jump only) = 위로 점프 (그대로) - Drop-Through (Down + Jump) = 발판 통과 + 점프 모션 + 자연 낙하 - 0.3초 후 mask 자동 복원 (다른 발판 위 정상 착지 가능) 후속 의무: - PD Refresh+Play 시각 검증 (발판 위 + Down + Jump → 통과·낙하 + 점프 애니메이션) - 정합 시 BT49~BT65 영구 폐기 + R2 + BT68 + BT69 영역 영구 채택
2026-05-07 15:26:12 +00:00
{
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
// Down + Jump 발판 위 = Drop-Through 발동 / 지면 위 = 일반 점프
BT5-Dev #69: Down + Jump Drop-Through 입력 추가 (PD 명시 채택) PD 명시 (2026-05-08): "발판과 같이 아래가 뚫려있고 이동 가능한 영역이 있는 경우, 아래 방향키 상태로 점프하면 점프 모션과 함께 내려올 수 있도록" 표준 platformer 패턴 (Drop-Through Input): - Player가 발판(Layer 16) 위 + Down 방향키 + Jump 키 동시 입력 - = Layer 16 mask 강제 OFF (DROP_THROUGH_DURATION=0.3초) → 발판 통과 - = velocity.y = 0 (위 점프 X·gravity로 자연 낙하) - = jumpState = PrepareToJump (점프 애니메이션 발동·시각상 점프 모션) 변경 (PlayerController.cs 3영역): 1. 클래스 변수 추가: - float dropThroughTimer (Layer 16 mask 강제 OFF 지속 시간) - const float DROP_THROUGH_DURATION = 0.3f - bool dropThroughJump (본 frame Drop-Through 점프 발동 분기) 2. Update 영역: - Move Input 영역 y < -0.5 (Down) + Jump WasPressed → dropThroughTimer 활성 + dropThroughJump=true - 매 frame dropThroughTimer 감소 (Time.deltaTime) 3. UpdateContactFilterForDropThrough 영역: - isJumpingThrough 조건에 dropThroughTimer > 0 추가 - Drop-Through 활성 시 Layer 16 mask 강제 OFF 4. ComputeVelocity 영역: - jump && IsGrounded 시 dropThroughJump 분기: - dropThroughJump → velocity.y = 0 (위 점프 X) - else → velocity.y = jumpTakeOffSpeed (기존 정상 점프) 효과 (PD 의도 정합): - 일반 점프 (Jump only) = 위로 점프 (그대로) - Drop-Through (Down + Jump) = 발판 통과 + 점프 모션 + 자연 낙하 - 0.3초 후 mask 자동 복원 (다른 발판 위 정상 착지 가능) 후속 의무: - PD Refresh+Play 시각 검증 (발판 위 + Down + Jump → 통과·낙하 + 점프 애니메이션) - 정합 시 BT49~BT65 영구 폐기 + R2 + BT68 + BT69 영역 영구 채택
2026-05-07 15:26:12 +00:00
bool downHeld = moveInput.y < -0.5f;
bool onJumpThroughPlatform = false;
if (downHeld && collider2d != null)
{
Vector2 dropFootPos = new Vector2(collider2d.bounds.center.x, collider2d.bounds.min.y + 0.02f);
int jumpThroughMask = 1 << JUMP_THROUGH_LAYER;
RaycastHit2D dropFootHit = Physics2D.Raycast(dropFootPos, Vector2.down, 0.1f, jumpThroughMask);
onJumpThroughPlatform = dropFootHit.collider != null;
}
if (downHeld && onJumpThroughPlatform)
BT5-Dev #69: Down + Jump Drop-Through 입력 추가 (PD 명시 채택) PD 명시 (2026-05-08): "발판과 같이 아래가 뚫려있고 이동 가능한 영역이 있는 경우, 아래 방향키 상태로 점프하면 점프 모션과 함께 내려올 수 있도록" 표준 platformer 패턴 (Drop-Through Input): - Player가 발판(Layer 16) 위 + Down 방향키 + Jump 키 동시 입력 - = Layer 16 mask 강제 OFF (DROP_THROUGH_DURATION=0.3초) → 발판 통과 - = velocity.y = 0 (위 점프 X·gravity로 자연 낙하) - = jumpState = PrepareToJump (점프 애니메이션 발동·시각상 점프 모션) 변경 (PlayerController.cs 3영역): 1. 클래스 변수 추가: - float dropThroughTimer (Layer 16 mask 강제 OFF 지속 시간) - const float DROP_THROUGH_DURATION = 0.3f - bool dropThroughJump (본 frame Drop-Through 점프 발동 분기) 2. Update 영역: - Move Input 영역 y < -0.5 (Down) + Jump WasPressed → dropThroughTimer 활성 + dropThroughJump=true - 매 frame dropThroughTimer 감소 (Time.deltaTime) 3. UpdateContactFilterForDropThrough 영역: - isJumpingThrough 조건에 dropThroughTimer > 0 추가 - Drop-Through 활성 시 Layer 16 mask 강제 OFF 4. ComputeVelocity 영역: - jump && IsGrounded 시 dropThroughJump 분기: - dropThroughJump → velocity.y = 0 (위 점프 X) - else → velocity.y = jumpTakeOffSpeed (기존 정상 점프) 효과 (PD 의도 정합): - 일반 점프 (Jump only) = 위로 점프 (그대로) - Drop-Through (Down + Jump) = 발판 통과 + 점프 모션 + 자연 낙하 - 0.3초 후 mask 자동 복원 (다른 발판 위 정상 착지 가능) 후속 의무: - PD Refresh+Play 시각 검증 (발판 위 + Down + Jump → 통과·낙하 + 점프 애니메이션) - 정합 시 BT49~BT65 영구 폐기 + R2 + BT68 + BT69 영역 영구 채택
2026-05-07 15:26:12 +00:00
{
dropThroughTimer = DROP_THROUGH_DURATION;
dropThroughJump = true;
}
jumpState = JumpState.PrepareToJump;
BT5-Dev #69: Down + Jump Drop-Through 입력 추가 (PD 명시 채택) PD 명시 (2026-05-08): "발판과 같이 아래가 뚫려있고 이동 가능한 영역이 있는 경우, 아래 방향키 상태로 점프하면 점프 모션과 함께 내려올 수 있도록" 표준 platformer 패턴 (Drop-Through Input): - Player가 발판(Layer 16) 위 + Down 방향키 + Jump 키 동시 입력 - = Layer 16 mask 강제 OFF (DROP_THROUGH_DURATION=0.3초) → 발판 통과 - = velocity.y = 0 (위 점프 X·gravity로 자연 낙하) - = jumpState = PrepareToJump (점프 애니메이션 발동·시각상 점프 모션) 변경 (PlayerController.cs 3영역): 1. 클래스 변수 추가: - float dropThroughTimer (Layer 16 mask 강제 OFF 지속 시간) - const float DROP_THROUGH_DURATION = 0.3f - bool dropThroughJump (본 frame Drop-Through 점프 발동 분기) 2. Update 영역: - Move Input 영역 y < -0.5 (Down) + Jump WasPressed → dropThroughTimer 활성 + dropThroughJump=true - 매 frame dropThroughTimer 감소 (Time.deltaTime) 3. UpdateContactFilterForDropThrough 영역: - isJumpingThrough 조건에 dropThroughTimer > 0 추가 - Drop-Through 활성 시 Layer 16 mask 강제 OFF 4. ComputeVelocity 영역: - jump && IsGrounded 시 dropThroughJump 분기: - dropThroughJump → velocity.y = 0 (위 점프 X) - else → velocity.y = jumpTakeOffSpeed (기존 정상 점프) 효과 (PD 의도 정합): - 일반 점프 (Jump only) = 위로 점프 (그대로) - Drop-Through (Down + Jump) = 발판 통과 + 점프 모션 + 자연 낙하 - 0.3초 후 mask 자동 복원 (다른 발판 위 정상 착지 가능) 후속 의무: - PD Refresh+Play 시각 검증 (발판 위 + Down + Jump → 통과·낙하 + 점프 애니메이션) - 정합 시 BT49~BT65 영구 폐기 + R2 + BT68 + BT69 영역 영구 채택
2026-05-07 15:26:12 +00:00
}
else if (m_JumpAction.WasReleasedThisFrame())
{
stopJump = true;
Schedule<PlayerStopJump>().player = this;
}
// 공격은 PlayerAttackTicker가 자동 주기로 Schedule<PlayerAttack>을 발화 (BT7-Plan VS 순수형).
}
else
{
move.x = 0;
}
BT5-Dev #69: Down + Jump Drop-Through 입력 추가 (PD 명시 채택) PD 명시 (2026-05-08): "발판과 같이 아래가 뚫려있고 이동 가능한 영역이 있는 경우, 아래 방향키 상태로 점프하면 점프 모션과 함께 내려올 수 있도록" 표준 platformer 패턴 (Drop-Through Input): - Player가 발판(Layer 16) 위 + Down 방향키 + Jump 키 동시 입력 - = Layer 16 mask 강제 OFF (DROP_THROUGH_DURATION=0.3초) → 발판 통과 - = velocity.y = 0 (위 점프 X·gravity로 자연 낙하) - = jumpState = PrepareToJump (점프 애니메이션 발동·시각상 점프 모션) 변경 (PlayerController.cs 3영역): 1. 클래스 변수 추가: - float dropThroughTimer (Layer 16 mask 강제 OFF 지속 시간) - const float DROP_THROUGH_DURATION = 0.3f - bool dropThroughJump (본 frame Drop-Through 점프 발동 분기) 2. Update 영역: - Move Input 영역 y < -0.5 (Down) + Jump WasPressed → dropThroughTimer 활성 + dropThroughJump=true - 매 frame dropThroughTimer 감소 (Time.deltaTime) 3. UpdateContactFilterForDropThrough 영역: - isJumpingThrough 조건에 dropThroughTimer > 0 추가 - Drop-Through 활성 시 Layer 16 mask 강제 OFF 4. ComputeVelocity 영역: - jump && IsGrounded 시 dropThroughJump 분기: - dropThroughJump → velocity.y = 0 (위 점프 X) - else → velocity.y = jumpTakeOffSpeed (기존 정상 점프) 효과 (PD 의도 정합): - 일반 점프 (Jump only) = 위로 점프 (그대로) - Drop-Through (Down + Jump) = 발판 통과 + 점프 모션 + 자연 낙하 - 0.3초 후 mask 자동 복원 (다른 발판 위 정상 착지 가능) 후속 의무: - PD Refresh+Play 시각 검증 (발판 위 + Down + Jump → 통과·낙하 + 점프 애니메이션) - 정합 시 BT49~BT65 영구 폐기 + R2 + BT68 + BT69 영역 영구 채택
2026-05-07 15:26:12 +00:00
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
// Drop-Through·Jump Ascent Timer 감소 (mask 강제 OFF 지속 시간)
BT5-Dev #69: Down + Jump Drop-Through 입력 추가 (PD 명시 채택) PD 명시 (2026-05-08): "발판과 같이 아래가 뚫려있고 이동 가능한 영역이 있는 경우, 아래 방향키 상태로 점프하면 점프 모션과 함께 내려올 수 있도록" 표준 platformer 패턴 (Drop-Through Input): - Player가 발판(Layer 16) 위 + Down 방향키 + Jump 키 동시 입력 - = Layer 16 mask 강제 OFF (DROP_THROUGH_DURATION=0.3초) → 발판 통과 - = velocity.y = 0 (위 점프 X·gravity로 자연 낙하) - = jumpState = PrepareToJump (점프 애니메이션 발동·시각상 점프 모션) 변경 (PlayerController.cs 3영역): 1. 클래스 변수 추가: - float dropThroughTimer (Layer 16 mask 강제 OFF 지속 시간) - const float DROP_THROUGH_DURATION = 0.3f - bool dropThroughJump (본 frame Drop-Through 점프 발동 분기) 2. Update 영역: - Move Input 영역 y < -0.5 (Down) + Jump WasPressed → dropThroughTimer 활성 + dropThroughJump=true - 매 frame dropThroughTimer 감소 (Time.deltaTime) 3. UpdateContactFilterForDropThrough 영역: - isJumpingThrough 조건에 dropThroughTimer > 0 추가 - Drop-Through 활성 시 Layer 16 mask 강제 OFF 4. ComputeVelocity 영역: - jump && IsGrounded 시 dropThroughJump 분기: - dropThroughJump → velocity.y = 0 (위 점프 X) - else → velocity.y = jumpTakeOffSpeed (기존 정상 점프) 효과 (PD 의도 정합): - 일반 점프 (Jump only) = 위로 점프 (그대로) - Drop-Through (Down + Jump) = 발판 통과 + 점프 모션 + 자연 낙하 - 0.3초 후 mask 자동 복원 (다른 발판 위 정상 착지 가능) 후속 의무: - PD Refresh+Play 시각 검증 (발판 위 + Down + Jump → 통과·낙하 + 점프 애니메이션) - 정합 시 BT49~BT65 영구 폐기 + R2 + BT68 + BT69 영역 영구 채택
2026-05-07 15:26:12 +00:00
if (dropThroughTimer > 0f) dropThroughTimer -= Time.deltaTime;
if (jumpAscentTimer > 0f) jumpAscentTimer -= Time.deltaTime;
UpdateJumpState();
base.Update();
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
// 낙사 시 복귀할 안전 위치 추적
if (IsGrounded) LastGroundedPosition = transform.position;
}
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
// Drop-Through Layer (Foreground·AutoForeground GameObject Layer 16).
// KinematicObject body.Cast의 contactFilter는 Start() 시점 캐싱되므로 Drop-Through는 SetLayerMask 동적 갱신으로 처리.
const int JUMP_THROUGH_LAYER = 16;
void UpdateJumpState()
{
jump = false;
switch (jumpState)
{
case JumpState.PrepareToJump:
jumpState = JumpState.Jumping;
jump = true;
stopJump = false;
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
// 일반 점프만 ascending 통과 보장 Timer 활성 (Drop-Through는 dropThroughTimer로 처리)
if (!dropThroughJump) jumpAscentTimer = JUMP_ASCENT_DURATION;
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
// PrepareToJump frame 즉시 mask OFF — 다음 frame ComputeVelocity의 velocity.y 적용 직전 발판 충돌 차단
{
int baseMaskJump = Physics2D.GetLayerCollisionMask(gameObject.layer);
contactFilter.SetLayerMask(baseMaskJump & ~(1 << JUMP_THROUGH_LAYER));
contactFilter.useLayerMask = true;
}
break;
case JumpState.Jumping:
if (!IsGrounded)
{
Schedule<PlayerJumped>().player = this;
jumpState = JumpState.InFlight;
}
break;
case JumpState.InFlight:
if (IsGrounded)
{
Schedule<PlayerLanded>().player = this;
jumpState = JumpState.Landed;
}
break;
case JumpState.Landed:
jumpState = JumpState.Grounded;
break;
}
UpdateContactFilterForDropThrough();
}
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
/// <summary>
/// Drop-Through 패턴: ascending·정점·Drop-Through Timer 활성 시 Layer 16 mask OFF (통과).
/// 그 외 = footHit 3점 Raycast (Layer 16) — 발판 가장자리 안정 검출.
/// 점프·낙하 중 정점 영역 + 수평 입력 + 발판 가장자리 일시 검출 = 밀림 상태 → 강제 Drop-Through 발동.
/// </summary>
void UpdateContactFilterForDropThrough()
{
int baseMask = Physics2D.GetLayerCollisionMask(gameObject.layer);
bool isJumpingThrough = jumpState == JumpState.Jumping
BT5-Dev #69: Down + Jump Drop-Through 입력 추가 (PD 명시 채택) PD 명시 (2026-05-08): "발판과 같이 아래가 뚫려있고 이동 가능한 영역이 있는 경우, 아래 방향키 상태로 점프하면 점프 모션과 함께 내려올 수 있도록" 표준 platformer 패턴 (Drop-Through Input): - Player가 발판(Layer 16) 위 + Down 방향키 + Jump 키 동시 입력 - = Layer 16 mask 강제 OFF (DROP_THROUGH_DURATION=0.3초) → 발판 통과 - = velocity.y = 0 (위 점프 X·gravity로 자연 낙하) - = jumpState = PrepareToJump (점프 애니메이션 발동·시각상 점프 모션) 변경 (PlayerController.cs 3영역): 1. 클래스 변수 추가: - float dropThroughTimer (Layer 16 mask 강제 OFF 지속 시간) - const float DROP_THROUGH_DURATION = 0.3f - bool dropThroughJump (본 frame Drop-Through 점프 발동 분기) 2. Update 영역: - Move Input 영역 y < -0.5 (Down) + Jump WasPressed → dropThroughTimer 활성 + dropThroughJump=true - 매 frame dropThroughTimer 감소 (Time.deltaTime) 3. UpdateContactFilterForDropThrough 영역: - isJumpingThrough 조건에 dropThroughTimer > 0 추가 - Drop-Through 활성 시 Layer 16 mask 강제 OFF 4. ComputeVelocity 영역: - jump && IsGrounded 시 dropThroughJump 분기: - dropThroughJump → velocity.y = 0 (위 점프 X) - else → velocity.y = jumpTakeOffSpeed (기존 정상 점프) 효과 (PD 의도 정합): - 일반 점프 (Jump only) = 위로 점프 (그대로) - Drop-Through (Down + Jump) = 발판 통과 + 점프 모션 + 자연 낙하 - 0.3초 후 mask 자동 복원 (다른 발판 위 정상 착지 가능) 후속 의무: - PD Refresh+Play 시각 검증 (발판 위 + Down + Jump → 통과·낙하 + 점프 애니메이션) - 정합 시 BT49~BT65 영구 폐기 + R2 + BT68 + BT69 영역 영구 채택
2026-05-07 15:26:12 +00:00
|| (jumpState == JumpState.InFlight && velocity.y > 0.01f)
|| dropThroughTimer > 0f
|| jumpAscentTimer > 0f;
bool standingOnPlatform = false;
if (collider2d != null && !isJumpingThrough)
{
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
// footHit Raycast 3점 (좌·중·우) — 가장자리 jitter 차단
float footY = collider2d.bounds.min.y + 0.02f;
float boundsLeft = collider2d.bounds.min.x + 0.02f;
float boundsCenter = collider2d.bounds.center.x;
float boundsRight = collider2d.bounds.max.x - 0.02f;
int jumpThroughMask = 1 << JUMP_THROUGH_LAYER;
RaycastHit2D footHitC = Physics2D.Raycast(new Vector2(boundsCenter, footY), Vector2.down, 0.1f, jumpThroughMask);
RaycastHit2D footHitL = Physics2D.Raycast(new Vector2(boundsLeft, footY), Vector2.down, 0.1f, jumpThroughMask);
RaycastHit2D footHitR = Physics2D.Raycast(new Vector2(boundsRight, footY), Vector2.down, 0.1f, jumpThroughMask);
standingOnPlatform = footHitC.collider != null || footHitL.collider != null || footHitR.collider != null;
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
// 밀림 상태 강제 Drop-Through (점프·낙하 중 정점 + 수평 입력 + 발판 가장자리 일시 검출)
bool inAir = jumpState == JumpState.Jumping || jumpState == JumpState.InFlight;
bool nearApex = velocity.y > -1.5f;
bool horizontalIntent = Mathf.Abs(move.x) > 0.1f;
if (standingOnPlatform && inAir && nearApex && horizontalIntent)
{
dropThroughTimer = DROP_THROUGH_DURATION;
standingOnPlatform = false;
}
}
int mask = standingOnPlatform ? baseMask : (baseMask & ~(1 << JUMP_THROUGH_LAYER));
contactFilter.SetLayerMask(mask);
contactFilter.useLayerMask = true;
}
protected override void ComputeVelocity()
{
if (jump && IsGrounded)
{
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
// Drop-Through 점프: 위로 점프 X (음수 velocity.y로 즉시 낙하 시작 + 점프 애니메이션만 유지)
BT5-Dev #69: Down + Jump Drop-Through 입력 추가 (PD 명시 채택) PD 명시 (2026-05-08): "발판과 같이 아래가 뚫려있고 이동 가능한 영역이 있는 경우, 아래 방향키 상태로 점프하면 점프 모션과 함께 내려올 수 있도록" 표준 platformer 패턴 (Drop-Through Input): - Player가 발판(Layer 16) 위 + Down 방향키 + Jump 키 동시 입력 - = Layer 16 mask 강제 OFF (DROP_THROUGH_DURATION=0.3초) → 발판 통과 - = velocity.y = 0 (위 점프 X·gravity로 자연 낙하) - = jumpState = PrepareToJump (점프 애니메이션 발동·시각상 점프 모션) 변경 (PlayerController.cs 3영역): 1. 클래스 변수 추가: - float dropThroughTimer (Layer 16 mask 강제 OFF 지속 시간) - const float DROP_THROUGH_DURATION = 0.3f - bool dropThroughJump (본 frame Drop-Through 점프 발동 분기) 2. Update 영역: - Move Input 영역 y < -0.5 (Down) + Jump WasPressed → dropThroughTimer 활성 + dropThroughJump=true - 매 frame dropThroughTimer 감소 (Time.deltaTime) 3. UpdateContactFilterForDropThrough 영역: - isJumpingThrough 조건에 dropThroughTimer > 0 추가 - Drop-Through 활성 시 Layer 16 mask 강제 OFF 4. ComputeVelocity 영역: - jump && IsGrounded 시 dropThroughJump 분기: - dropThroughJump → velocity.y = 0 (위 점프 X) - else → velocity.y = jumpTakeOffSpeed (기존 정상 점프) 효과 (PD 의도 정합): - 일반 점프 (Jump only) = 위로 점프 (그대로) - Drop-Through (Down + Jump) = 발판 통과 + 점프 모션 + 자연 낙하 - 0.3초 후 mask 자동 복원 (다른 발판 위 정상 착지 가능) 후속 의무: - PD Refresh+Play 시각 검증 (발판 위 + Down + Jump → 통과·낙하 + 점프 애니메이션) - 정합 시 BT49~BT65 영구 폐기 + R2 + BT68 + BT69 영역 영구 채택
2026-05-07 15:26:12 +00:00
if (dropThroughJump)
{
BT5-Dev #75: 발판 시스템 영구 마무리 — 시행착오 주석 정리·dead code 제거 PD 명시 (2026-05-08): "플레이어 조작 시스템 완성. 시행착오로 불필요하게 생성된 코드·작업물 제거 + 최신 상태로만 깔끔하게" 정리 영역: 1. GameOptimizer.cs (Write 전체 재작성): - 헤더 주석 — BT5-Dev 발판 시스템 영구 영역 명시 + 동작 요약 5단계 - BT34·BT46·BT66·BT67·BT48·BT63·BT68 시행착오 주석 영역 통합 정리 - Debug.Log 영역 통합 1행 ([GameOptimizer] 출력) - IsSmallAirPlatform 헬퍼 영역 보존 (BT48 휴리스틱 사용 중) 2. PlayerController.cs (Edit 부분 정리): - dropThroughTimer·jumpAscentTimer 변수 영역 주석 정리 - OnCollisionEnter2D BT30-Collide 진단 Debug.Log 영역 폐기 (시행착오) - BT69·BT70·BT71·BT72·BT73·BT74 시행착오 주석 영역 통합 정리 - UpdateContactFilterForDropThrough 영역 메서드 docstring 추가 3. KinematicObject.cs (Edit 부분 정리): - BT68 X·Y 분리 영역 주석 정리 영구 채택 영역: - R2 (BT66): AutoForeground GameObject 분리 + PD Foreground = 가림막 시각만 - BT67: AutoForeground transform 동기화 (PD Foreground·Level 영역과 동일) - BT68: KinematicObject X·Y 분리 + GameOptimizer TileGround* 자동 분류 제외 - BT69~BT74: Drop-Through (Down + Jump) Input 패턴 + 가장자리 jitter 차단 플레이어 조작 시스템 완성: - 발판 위 착지·점프 통과·자유 이동 - Down + Jump = Drop-Through (발판 위만) - 전진 점프 시 앞 벽 hit + 위로 점프 보존 - 대각선 벽 통과 X (TileGround* Level 잔존) - 발판 가장자리 jitter 차단 (3점 Raycast + 밀림 강제 Drop-Through)
2026-05-07 15:49:26 +00:00
velocity.y = -0.5f;
BT5-Dev #69: Down + Jump Drop-Through 입력 추가 (PD 명시 채택) PD 명시 (2026-05-08): "발판과 같이 아래가 뚫려있고 이동 가능한 영역이 있는 경우, 아래 방향키 상태로 점프하면 점프 모션과 함께 내려올 수 있도록" 표준 platformer 패턴 (Drop-Through Input): - Player가 발판(Layer 16) 위 + Down 방향키 + Jump 키 동시 입력 - = Layer 16 mask 강제 OFF (DROP_THROUGH_DURATION=0.3초) → 발판 통과 - = velocity.y = 0 (위 점프 X·gravity로 자연 낙하) - = jumpState = PrepareToJump (점프 애니메이션 발동·시각상 점프 모션) 변경 (PlayerController.cs 3영역): 1. 클래스 변수 추가: - float dropThroughTimer (Layer 16 mask 강제 OFF 지속 시간) - const float DROP_THROUGH_DURATION = 0.3f - bool dropThroughJump (본 frame Drop-Through 점프 발동 분기) 2. Update 영역: - Move Input 영역 y < -0.5 (Down) + Jump WasPressed → dropThroughTimer 활성 + dropThroughJump=true - 매 frame dropThroughTimer 감소 (Time.deltaTime) 3. UpdateContactFilterForDropThrough 영역: - isJumpingThrough 조건에 dropThroughTimer > 0 추가 - Drop-Through 활성 시 Layer 16 mask 강제 OFF 4. ComputeVelocity 영역: - jump && IsGrounded 시 dropThroughJump 분기: - dropThroughJump → velocity.y = 0 (위 점프 X) - else → velocity.y = jumpTakeOffSpeed (기존 정상 점프) 효과 (PD 의도 정합): - 일반 점프 (Jump only) = 위로 점프 (그대로) - Drop-Through (Down + Jump) = 발판 통과 + 점프 모션 + 자연 낙하 - 0.3초 후 mask 자동 복원 (다른 발판 위 정상 착지 가능) 후속 의무: - PD Refresh+Play 시각 검증 (발판 위 + Down + Jump → 통과·낙하 + 점프 애니메이션) - 정합 시 BT49~BT65 영구 폐기 + R2 + BT68 + BT69 영역 영구 채택
2026-05-07 15:26:12 +00:00
dropThroughJump = false;
}
else
{
velocity.y = jumpTakeOffSpeed * model.jumpModifier;
}
jump = false;
}
else if (stopJump)
{
stopJump = false;
if (velocity.y > 0)
{
velocity.y = velocity.y * model.jumpDeceleration;
}
}
if (move.x > 0.01f)
{
spriteRenderer.flipX = true;
facing = Vector2.right;
}
else if (move.x < -0.01f)
{
spriteRenderer.flipX = false;
facing = Vector2.left;
}
animator.SetBool("grounded", IsGrounded);
animator.SetFloat("velocityX", Mathf.Abs(velocity.x) / maxSpeed);
targetVelocity = move * maxSpeed;
}
public enum JumpState
{
Grounded,
PrepareToJump,
Jumping,
InFlight,
Landed
}
}
}