[내일배움캠프 본 캠프]코드카타, GAS(2)(2025/06/05)

김세훈·2025년 6월 5일
0

1) 코드카타

문제(나누어 떨어지는 숫자 배열)
https://school.programmers.co.kr/learn/courses/30/lessons/12910

제출한 답안

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> solution(vector<int> arr, int divisor) {
    vector<int> answer;
    
    for (int i = 0; i < arr.size(); i++)
    {
        if (arr[i] % divisor == 0)
        {
            answer.push_back(arr[i]);
        }
    }
    if (answer.size() == 0)
    {
        answer.push_back(-1);
        return answer;
    }
     sort(answer.begin(), answer.end());
    
    return answer;
}

문제(음양 더하기)
https://school.programmers.co.kr/learn/courses/30/lessons/76501

제출한 답안

#include <string>
#include <vector>

using namespace std;

int solution(vector<int> absolutes, vector<bool> signs) {
    int answer = 0;
    
    for (int i = 0; i < signs.size(); i++)
    {
        if (signs[i] == true)
        {
            answer += absolutes[i];
        }
        else
        {
            answer += absolutes[i] - absolutes[i] * 2;
        }
    }
    
    return answer;
}

문제(핸드폰 번호 가리기)
https://school.programmers.co.kr/learn/courses/30/lessons/12948

제출한 답안

#include <string>
#include <vector>
#include <iostream>

using namespace std;

string solution(string phone_number) {
    string answer = "";
    int numberSize = phone_number.size();
    string hide{};
    string backNumber = phone_number.substr(numberSize - 4);
    
    for (int i = 0; i < numberSize - 4; i++)
    {
        hide.push_back('*');
    }
    answer = hide + backNumber;
    
    
    return answer;
}

문제(없는 숫자 더하기)
https://school.programmers.co.kr/learn/courses/30/lessons/86051

제출한 답안

#include <string>
#include <vector>
#include <iostream>

using namespace std;

int solution(vector<int> numbers) {
    int answer = 0;
    
    for (int i = 0; i <= 9; i++)
    {
        bool isFind = false;
        
        for (int j = 0; j < numbers.size(); j++)
        {
            if (numbers[j] == i)
            {
                isFind = true;
                j = numbers.size();
            }
        }
        if (!isFind)
        {
            answer += i;
        }
    }
    return answer;
}

isFind가 for문 안에 있어야 한다. 숫자 하나를 찾고나면 다시 false부터 했어야 했는데 맨 위에 적어두니 한번 찾아서 true로 바뀐게 그대로 저장돼서 0부터 9까지 전부 더하거나 하나도 더하지 않았다.


2) GAS 시스템

Gameeplay Effects(GE)는 ACS의 상태에 추가되거나 제거되지 않고 단순히 실행 된다.

언리얼 엔진에서 GameplayEffect로 클래스 생성
Duration에서 즉시, 무한, 기간으로 설정할 수 있다.
아래 사진처럼 세팅 및 캐릭터 블루프린트에서 X키로 디버깅하게 만든 후 디버그 창에서 X를 누르면 체력이 15씩 빠지는 걸 볼 수 있다.

이 방법이 싱글 플레이어에서는 즉시 적용되는데 멀티 플레이어에서는 다른 작업을 해야 한다.

멀티 플레이어 프로젝트에서 진행 중이라면 위 사진 만들어야 한다.
(본인은 싱글 플레이어로 해서 못 해봤다.)

이렇게 고정값을 주는 경우도 있을 수 있지만 보통은 게임 중에 값을 조회하거나 계산 한다. 그럴 때 사용할 수 있는 기능들이 있다.

  • Scalable Float
    적용된 GE 레벨에 따라 확장되는 수치이다. 이 레벨은 플레이어의 진행 상황을 통해 특전 트리, 게임 난이도 설정, 적 NPC 레벨 등을 결정할 수 있다.
  • Custom Calculation Class
    수정자(modifier) 값을 계산하거나 가져오는 방법에 대한 자체 로직을 제공할 수 있다. 예를 들어, 액터 속성이나 함수, 현재 이동속도 기반 또는 캐릭터가 웅크리고 있는지, 방어하고 있는지, 달리고 있는지에 따라 영향을 받을 수 있다.
  • Set By Caller
    GameplayTag에 저장되는 사용자 지정 값을 제공할 수 있는데 이 값은 속성 수정자로 직접 사용하거나 GE Executions의 사용자 지정 로직을 통해 가져올 수 있다. Set By Caller의 좋은 예로 충돌 이벤트의 충돌 속도에 따라 피해량이나 넉백 강도가 영향을 받는 경우이다.
  • Meta Attributes and Executions(엔진에 남은 건 attribute based인데 이거인지 모르겠음)
    디자이너가 속성 수정자가 제공하는 것보다 더 복잡한 공식을 구현하거나 크리티컬 확률, 회피 확률, 입력된 데미지 저항과 같은 게임 디자인 특정 단계를 포함하려는 경우, 메타 속성을 도입하고 GameplayEffectExecutionCalculation클래스에서 서버 측에서 계산을 수행하는 것이 일반적이다. 이를 통해 실행 속성을 구성하여 GameplayEffect를 적용할 때 사용자 지정 논리를 실행할 수 있다.

지금 공부 중인 페이지가 그나마 최신 문서라고 해도 나중에 옛날 인풋 시스템을 써서 안되는 부분이 있어서 빠르게 넘기듯이 하고 바로 Lyra 프로젝트 분석이 들어간다.
https://dev.epicgames.com/community/learning/tutorials/8Xn9/unreal-engine-epic-for-indies-your-first-60-minutes-with-gameplay-ability-system#introductiontogameplayeffects

profile
내일배움캠프 언리얼 과정 열심히 듣기 화이팅!

0개의 댓글