프로그래밍 528

2DRPG 타겟 탐지 기능 - ComBatSystem

https://github.com/kwon1232/RPG_2D GitHub - kwon1232/RPG_2D: RPG_2DRPG_2D. Contribute to kwon1232/RPG_2D development by creating an account on GitHub.github.com 일단 Attack 애니메이션의 어느 부분에 타겟을 인지할 지 정해야 한다.이는 이벤트 트리거 스크립트를 이용하여 AttackTrigger() 함수를 바인딩해준다.public class Entity_AnimationTriggers : MonoBehaviour{ private Entity entity; private Entity_Combat entityCombat; private void Awake() ..

2D RPG - 플레이어를 인식하는 enemy AI

Enemy AI가 플레이어를 인식해야순찰 혹은 IDLE 상태에서 chasing 상태 혹은 attack 상태로 변화할 수 있다.따라서 적군이 플레이어를 인식하는 것은가장 필요한 기초적인 단계이다. 이러한 단계는 다음과 같이 접근할 수 있다. protected virtual void OnDrawGizmos() { Gizmos.DrawLine(groundCheck.position, groundCheck.position + new Vector3(0, -groundCheckDistance)); Gizmos.DrawLine(primaryWallCheck.position, primaryWallCheck.position + new Vector3(wallCheckDistance * ..

몬스터 ai의 ground checking

몬스터의 ground check는 다음과 같은 이유를 비롯하여 필요로 한다. 땅 위에 있는지(낙하/점프/계단) 판단경사/단차/절벽 감지(앞으로 가도 되는지)네비/이동 로직 보정(공중에서 이동 금지, 슬립 방지, 스텝 처리)따라서 오늘은 스켈레톤 클래스에서 ground check를 가능하게 하도록상위 구조의 코드를 변경하였다. 1. 부모 클래스의 코드 수정 아래는 변경 전 코드이다. private void HandleCollisionDetection() { groundDetected = Physics2D.Raycast(transform.position, Vector2.down, groundCheckDistance, whatIsGround); wallDetected = ..

프로그래머스 Lv.2 마법의 엘레베이터

https://school.programmers.co.kr/learn/courses/30/lessons/148653 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr#include #include using namespace std;int solution(int storey) { int answer = 0; while(storey > 0) { int cur = storey % 10; int next = (storey / 10) % 10; if(cur 5) { answer += 10 - cur; ..

프로그래머스 LV.2 튜플

https://school.programmers.co.kr/learn/courses/30/lessons/64065 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr #include #include #include #include using namespace std;bool cmp (pair& a, pair& b){ if(a.second == b.second) return a.first > b.first; return a.second > b.second;}vector solution(string s) { vector answer; map m; string temp = "..

2D RPG - 콤보 공격 만들기

복잡한 상태를 하위 계층 구조로 나누어 관리할 수 있는 sub state machine을 사용하여 콤보 공격을 구현하였다. 콤보 공격에 사용된 sub state machine의 내부 구조는 다음과 같다. 이런식으로 인덱스가 같으면 다음 인덱스로 넘어가게끔 한 것이다. 아래는 콤보 구현 방식 코드이다.using UnityEngine;public class Player_BasicAttackState : EntityState{ private float attackVelocityTimer; private const int FirstComboIndex = 1; private int comboIndex = 1; private int comboLimit = 3; public Player_B..

Unity 2026.01.07

DX - CPU에서 계산된 정보를 GPU로 넘기는 방법

void Game::Update(){ D3D11_MAPPED_SUBRESOURCE subResource; ZeroMemory(&subResource, sizeof(subResource)); _deviceContext->Map(_constantBuffer.Get(), 0, D3D11_MAP_WRITE, 0, &subResource); ::memcpy(subResource.pData, &_transformData, sizeof(_transformData)); _deviceContext->Unmap(_constantBuffer.Get(), 0);} 이 코드가 의미하는 바를 렌더링 파이프라인 관점에서 풀어보면Map / Unmap은 “Central Processing Unit가 쓸 수 있게 잠깐 문 열어주는 것”..

그래픽스/DX11 2025.12.18