[UE5] TIL - 12 <UGameplayStatics, GetWorldDeltaSeconds>

ChangJin·2024년 3월 29일
0

Unreal Engine5

목록 보기
39/102
post-thumbnail

2024-03-29

깃허브!
https://github.com/ChangJin-Lee/ARproject
https://github.com/ChangJin-Lee/ToonTank

느낀점
UGameplayStatics에 있는 GetWorldDeltaSeconds를 사용해 Delta Time 계산을 배웠다. UWorld가 모든 객체의 최상위 객체이고 게임에 관련된 모든 객체를 담고 있다고한다. 현재 객체를 가리킬때는 this를 사용하자. 카메라 프리뷰가 상당히 거슬렸는데 창 크기를 줄이는 방법을 알아냈다. 이제 편하게 개발이 가능하다.

TIL

  • UGameplayStatics
  • GetWorldDeltaSeconds
  • 씬 뷰 미리보기 창 사이즈 조절

UGameplayStatics

https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Runtime/Engine/Kismet/UGameplayStatics?application_version=5.3

  • 게임플레이에 관한 다양한 것들이 있는 Static 클래스이다. 블루프린트와 C++ 둘다에서 호출이 가능하다.


GetWorldDeltaSeconds

https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Runtime/Engine/Kismet/UGameplayStatics/GetWorldDeltaSeconds?application_version=5.3

  • 정확한 사용법은 다음과 같다.

UGameplayStatics::GetWorldDeltaSeconds


  • UGameplayStatics의 하위에 존재한다. 매개변수로 지금 우리가 어떤 월드에 있는지를 알려주어야한다. 그리고 반환값으로 델타 타임을 반환받는다.
  • 다음처럼 Move 함수를 완성해보았다. 헤더파일에는 private에 선언했다. 블루프린트에서 이 속도값을 변경하고 싶기 때문에 PROPERTY 지정자로 블루프린트에서 편집이 가능하도록 만들었다.

private:
	UPROPERTY(VisibleAnywhere, Category = "components")
	class USpringArmComponent* springarm;

	UPROPERTY(VisibleAnywhere, Category = "components")
	class UCameraComponent* camera;

	void Move(float Value);

	UPROPERTY(EditAnywhere, Category = "Movement")
	float moveSpeed = 300.0f;

void ATank::Move(float Value)
{
	FVector DeltaLocation = FVector::ZeroVector;
	double deltaTime = UGameplayStatics::GetWorldDeltaSeconds(this);
	DeltaLocation.X = Value * deltaTime * moveSpeed;
	AddActorLocalOffset(DeltaLocation);
}


씬 뷰 미리보기 창 사이즈 조절

https://makerejoicegames.tistory.com/296

  • 이거 자꾸 신경쓰였는데 이번에 방법을 알아냈다. 티스토리 블로그를 공유한다.

  • 다음처럼 Persprective 왼쪽에 있는 햄버거 메뉴를 클릭하고 Advanced Settings...를 누른다.

  • 그 다음 다른거 누르지말고 아래로 드래그하다보면 나오는 Lock and Feel에서 Camera Preview Size를 조절하면 된다.

  • 이제 짱편하게 개발 가능

업로드중..

profile
Unreal Engine 클라이언트 개발자

0개의 댓글