TIL

2/12일자 TIL

오딘.L.스트레인지 2026. 2. 12. 20:36

오늘은 코드카타 1개를 제출하고, 분반수업을 들었다.

그리고 팀프로젝트를 개인으로 하는 중, 기획을 진행하고 있다.

가장 가까운 같은 글자

 

#include <string>
#include <vector>
using namespace std;

vector<int> solution(string s) 
{
    vector<int> answer;

    int last[26];
    for (int i = 0; i < 26; i++) last[i] = -1;

    for (int i = 0; i < (int)s.size(); i++) 
    {
        char c = s[i];
        int idx = c - 'a';

        if (last[idx] == -1) 
        {
            answer.push_back(-1);
        } 
        else 
        {
            answer.push_back(i - last[idx]);
        }
        last[idx] = i;
    }

    return answer;
}

 

분반수업에서 배운 내용

더보기
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Animation/AnimInstance.h"
#include "PlayerAnimInstance.generated.h"

/**
 * 
 */
UCLASS()
class DARK_SOUL_Z_API UPlayerAnimInstance : public UAnimInstance
{
	GENERATED_BODY()
	

public:
	UPlayerAnimInstance();

protected:
	virtual void NativeInitializeAnimation() override; //애니메이션이 생성되면 호출되는 함수

	virtual void NativeUpdateAnimation(float DeltaSeconds) override; //프레임마다 호출 함수

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character")
	class ACharacter* Owner; //캐릭터 엑터

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character")
	class UCharacterMovementComponent* Movement; //Movement Component

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character")
	FVector Velocity; //Movement에 Velocity 속력을 저장하는 변수

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character") 
	float MoveSpeed; //속력에 벡터의 2D 구성요소의 길이를 저장하는 변수

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character")
	bool isFalling = false; //Ground에 닿여 있는지 여부

};
// Fill out your copyright notice in the Description page of Project Settings.


#include "Player/PlayerAnimInstance.h"
#include "GameFramework/Character.h"
#include "GameFramework/CharacterMovementComponent.h"

UPlayerAnimInstance::UPlayerAnimInstance() //생성자
{

}

void UPlayerAnimInstance::NativeInitializeAnimation() //애니메이션이 생성되면 호출되는 함수
{
	Super::NativeInitializeAnimation();

	Owner = Cast<ACharacter>(GetOwningActor());

	if (Owner)
	{
		Movement = Owner->GetCharacterMovement();
	}
}

void UPlayerAnimInstance::NativeUpdateAnimation(float DeltaSeconds) //프레임마다 호출
{
	Super::NativeUpdateAnimation(DeltaSeconds);

	if (Movement)
	{
		Velocity = Movement->Velocity;
		MoveSpeed = Velocity.Size2D(); //속력에 백터의 2D 구성요소의 길이를 대입
		isFalling = Movement->IsFalling(); 
	}
}

그리고 중간에 메시에서 본이 없어서 다른 메시로 대체하고 리타게팅을 하였다.

'TIL' 카테고리의 다른 글

2/19일자 TIL  (0) 2026.02.19
2/13일자 TIL  (0) 2026.02.13
2/11일자 TIL  (0) 2026.02.11
2/10일자 TIL  (0) 2026.02.10
2/09일자 TIL  (0) 2026.02.09