https://lunchballer.com/archives/366

 

[UE4] PhysicsHandleComponent로 임의의 오브젝트 잡기

#언리얼4 공부중 / UE4 버젼: 4.22.3  캐릭터가 임의의 오브젝트를 잡을 때 혹은 소유하고자 할때 어떻게 해야 할까. 유니티에서는 보통 두가지 방식을 사용 했었는데, 하나는 캐릭터에 빈 게임오브

lunchballer.com

 

https://docs.unrealengine.com/5.1/en-US/API/Runtime/Engine/PhysicsEngine/UPhysicsHandleComponent/

 

UPhysicsHandleComponent

Utility object for moving physics objects around.

docs.unrealengine.com

 

https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=thecookiesstudio&logNo=220593279578 

 

[언리얼엔진4 강좌] 피직스핸들 (PhysicsHandle)

안녕하세요. "Elibel" 입니다. 이번 포스팅에서는 'Physics Handle 컴포넌트'에 관해 강의, 포스팅을&nb...

blog.naver.com

 

https://mingyu0403.tistory.com/203

 

[Unreal BP] Physics Handle을 이용해 오브젝트 Grab하기

이 게시글은 움짤이 있습니다. 데이터가 많이 나갈 수도 있습니다. Physics Handle 컴포넌트 이 컴포넌트를 이용하면 오브젝트를 Grab하고 있을 수 있다. 자세한 내용은 언리얼 문서로 ㄱㄱ. https://docs

mingyu0403.tistory.com

 

https://lesslate.github.io/unreal4/%EC%96%B8%EB%A6%AC%EC%96%BC4-C++-%EC%98%A4%EB%B8%8C%EC%A0%9D%ED%8A%B8-%EC%9E%A1%EA%B8%B0/

 

언리얼4 C++ 오브젝트 잡기

Intro

lesslate.github.io

https://www.reddit.com/r/unrealengine/comments/5ykl5o/physics_handle_in_c/

 

From the unrealengine community on Reddit

Explore this post and more from the unrealengine community

www.reddit.com

 

UPhysicsComponent 의 PhysicHandle을 사용하여 물체를 옮길 수 있다

 

플레이어에(아마도) PhysicsHandleComponent 부착 후

SceneComponent 를 추가하여 Handle의 위치를 정해준다. (이름은 GrabLocation 정도로 하면 될 듯)

헤더, 소스파일에 선언 (소스파일의 beginplay에 CreateDefaultSubObject)

GrabComponentAtLocation() 과 RelaseComponent() 로 오브젝트를 잡거나 놓는 것이 가능함

 

E누르면 상속받은 인터랙트 발동 > 인터랙트에서 무버블로 보내주고

> 무버블에서 지금 잡고 있다면 놓는 함수 발동 / 잡고 있지 않다면 잡는 함수 발동 (컴포넌트가 비어 있으면?)

 


 

이라고 생각했는데,

사실 물건을 직접 옮기지 않아도 괜찮을 것 같다는 생각이 들었다

상호작용 키를 누르면 '물체가 움직이는 연출'이 나오고, 캐릭터가 물체를 움직이는 것처럼 나오지만 사실은 정해진 속도로 정해진 위치로 물체가 이동하는 매커니즘으로 만들어도 되지 않을까

(근데 이게 더 번거로울듯)

 


 

 

 

 

 

 

'[햄] 작업일기' 카테고리의 다른 글

230706  (0) 2023.07.07
230704  (0) 2023.07.04
230616  (0) 2023.06.16
230615  (0) 2023.06.15
230612-230613  (0) 2023.06.12

상속 시에는 상속하고 싶은 부모 함수는 무조건 virtual을 붙여주자

 

너무 당연한 얘기라 대장님도 잡아내지 못한.. ㅋㅋ 

 

 

가짜게임같네이제...

 

이것저것 한 것 같은데 오늘은 뭔가 쓸 내용이 별로 없는듯

 

해야 하는 거

대화창 전반적 수정
대화창 꺼지는 기능, 이름과 대사 받아오는 기능(아직 없어도 될 듯함), 대화창 켜지면 이동 불가

 

인터랙트 기능 수정

허공에 있을 때 hitResult에 아무 값도 들어가지 않도록 처리

'[햄] 작업일기' 카테고리의 다른 글

230704  (0) 2023.07.04
230625-230627  (0) 2023.06.24
230615  (0) 2023.06.15
230612-230613  (0) 2023.06.12
230603  (0) 2023.06.04

<위젯이 이미 있으면 띄우지 않는 기능>

#include "Components/SceneComponent.h"
//IsVisible()을 사용하기 위해 추가해야 하는 헤더

if(Widget->IsVisible())
{
  //코드 진행
}

SceneComponent 의 IsVisible()을 사용하여 판정

 

'[햄] 작업일기' 카테고리의 다른 글

230625-230627  (0) 2023.06.24
230616  (0) 2023.06.16
230612-230613  (0) 2023.06.12
230603  (0) 2023.06.04
230530  (0) 2023.05.31

12일

hitResult의 위치를 가져와서

거기에 띄우면 될듯!!! 진짜임


13일

hitResult가 부딪힌 액터의 위치를 가져와서

ProjectWorldLocationToScreen을 사용해서 FVector를 FVector2D로 바꿔줌

 

SetPositionInViewport로 위젯을 2D벡터 자리에 띄워줌

 

void AHamsterDemoCharacter::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);

	FHitResult hitResult;
	if (TraceOn(hitResult))
	{
		auto interactableObj = TraceInteractableObject(hitResult); // 감지한 물체가 상호 작용 가능한 물체인 지 체크
		if (interactableObj != nullptr)
		{
			bool isSuccessInteract = interactableObj->Interact(); // 물체에게 상호 작용 시도
			if (isSuccessInteract)
			{
				Widget->SetPositionInViewport(textLocation);
				Widget->AddToViewport(); //위젯 띄우기
			}
				

				// 상호 작용 성공 시 캐릭터가 할 행동 

			}
		}
	}
}

AInteractableObject* AHamsterDemoCharacter::TraceInteractableObject(struct FHitResult& inHit)
{
	auto actor = inHit.GetActor();
	if (actor == nullptr)
		return nullptr;

	const APlayerController* const PlayerController = Cast<const APlayerController>(GetController());
	FVector WorldLocation= actor->GetActorLocation();

	PlayerController->ProjectWorldLocationToScreen(WorldLocation, textLocation);

	return Cast<AInteractableObject>(actor);
}

 

이제 상호 작용 가능한 액터 자리에 텍스트가 뜬다.

 

위젯(텍스트)이 이미 띄워져 있으면 띄우지 않는 기능, 위젯이 3초 후 사라지는 기능도 넣어야 함 

 

<위젯이 이미 있으면 띄우지 않는 기능>

IsInViewport (블루프린트에는 있는데 코드로는 어떻게 하는지 모르겠음)?

IsVisible?

 

<위젯 n초 후 사라지기>

Delay 후 RemoveFromParents

FTimerHandle WaitHandle;
float WaitTime = 1.0; 
GetWorld()->GetTimerManager().SetTimer(WaitHandle, FTimerDelegate::CreateLambda([&]()
	{
		Widget->RemoveFromParent();

	}), WaitTime, false);

블루프린트의 Delay 기능을 SetTimer를 사용해서 구현할 수 있음

 

 

+)
하얀 네모가 생기면서 언리얼 에디터 뷰포트 창이 잠겼을 때

https://forums.unrealengine.com/t/viewport-locked/217697

 

Viewport locked?

Hey guys, First of all, it’s my first time using this forum so I hope I’m somewhat in the right category. (). Please move the Thread if not. I’m very new to Unreal and basically don’t have a real plan of what I’m doing yet so it happened, that I

forums.unrealengine.com

껐켰하거나

브라우저나 출력 탭... 여튼 다른 공간에서 뷰포트로 드래그 하면 풀린다는듯

두번째 방법은 안 해봐서 모르겠고 확실한 건 1번 ㅋㅋ 

'[햄] 작업일기' 카테고리의 다른 글

230616  (0) 2023.06.16
230615  (0) 2023.06.15
230603  (0) 2023.06.04
230530  (0) 2023.05.31
230528  (0) 2023.05.28

이제 인터랙트 가능할 때 화면에 뜬다...(액터 위에 떠야하는데도)
그래도 뜨는 게 어디임 ㅠ

 

<추측>

액터 위치를 받아서 거기에 붙여야 할듯

InteractableObject의 위치를 받아서 

> Convert World Location into Screen Location

set position in viewport

보고 있으면 알림 문구 유지

안 보면 1초 후 삭제 (delay 후 destroy나 remove from parent?)

 

 

 

 

'[햄] 작업일기' 카테고리의 다른 글

230615  (0) 2023.06.15
230612-230613  (0) 2023.06.12
230530  (0) 2023.05.31
230528  (0) 2023.05.28
230527  (0) 2023.05.27

FUdpSocketBuilder: Failed to create and initialize socket UdpMessageMulticastSocket 

위와 같은 메세지가 뜨면서 무한 컴파일

>> 네트워크 문제일 가능성이 높음.

VPN이나 네트워크 어댑터 문제일 수 있음.

랜선을 뽑고 무선랜으로 연결했더니 해결됨 (...)

 

해결하는데 참조한 글

https://forums.unrealengine.com/t/fudpsocketbuilder-errors-causing-frame-rate-drops-but-no-networking-in-project/467818/5

 

FUdpSocketBuilder errors causing frame rate drops but no networking in project

For me it stops after I connect to my workplace VPN. I set up SVN version control in engine and this error message begins pop up after VPN connection drops.

forums.unrealengine.com

 

 

블루프린트로 디자인한 UI 팝업을 가져오는데

경로 레퍼런스를 복사한 후

"/Game/UI/UI_InteractablePopup.UI_InteractablePopup_C"

_C 를 붙여줘야 정상적으로 불러올 수 있음

이유는 아직 모르겠는데 찾아봐야겠다. (클래스임을 나타내줘야 하는 것으로 추정?) 

'[햄] 작업일기' 카테고리의 다른 글

230612-230613  (0) 2023.06.12
230603  (0) 2023.06.04
230528  (0) 2023.05.28
230527  (0) 2023.05.27
230516  (0) 2023.05.16

'[햄] 작업일기' 카테고리의 다른 글

230603  (0) 2023.06.04
230530  (0) 2023.05.31
230527  (0) 2023.05.27
230516  (0) 2023.05.16
230509  (0) 2023.05.09

UPROPERTY( meta = (BindWidget) )

을 사용 시 블루프린트에서 이름과 형식이 같은 친구를 자동으로 바인딩 해줌 

 

텍스트블록이름->SetText( "들어갈내용~" )

이렇게 해서 띄워줄 수 있을 것 같은데

 

만들어둔 블루프린트 위젯을 가져다가 쓰는 건 아직 모르겠다

 

그리고 OnInteract쪽에 있는 발동 조건과 이 위젯을 어떻게 연결해야 할지도 아직 모르겠다

https://www.youtube.com/watch?v=bWoew0fa_xA 

내일 마저 봐야지~

 

+)

 

'[햄] 작업일기' 카테고리의 다른 글

230530  (0) 2023.05.31
230528  (0) 2023.05.28
230516  (0) 2023.05.16
230509  (0) 2023.05.09
230508  (0) 2023.05.08

+ Recent posts