11715人加入学习
(26人评价)
【旧版】Unreal基本知识案例 - 密室逃脱

旧版课程,制作完成于2017-01-11

价格 免费

上一节是绑定了抓取物品:

现在要移动物品:

if(PhysicsHandle && PhysicsHandle->GrabbedComponent)

{

    PhysicsHandle->SetTargetLocation(GetLineEnd());
}

 

PhysicsHandle ->ReleaseComponent();

[展开全文]

一直抓取着,在TickComponent中

// Called every frame
void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
	if (PhysicsHandle&&PhysicsHandle->GrabbedComponent)
	{
		PhysicsHandle->SetTargetLocation(GetLineEnd());
	}
}


void UGrabber::Grab()
{
	UE_LOG(LogTemp, Warning, TEXT("Grab action is pressed!"));
	FHitResult Hit = LineTrace();
	UPrimitiveComponent* ComponentToGrab = Hit.GetComponent();
	if (Hit.GetActor() && PhysicsHandle)
	{
		UE_LOG(LogTemp, Warning, TEXT("Grab!"));
		//PhysicsHandle->GrabComponent(ComponentToGrab, NAME_None, ComponentToGrab->GetOwner()->GetActorLocation(), true);
		PhysicsHandle->GrabComponentAtLocationWithRotation(ComponentToGrab, NAME_None, ComponentToGrab->GetOwner()->GetActorLocation(), GetOwner()->GetActorRotation());
	}
}


void UGrabber::Release()
{
	UE_LOG(LogTemp, Error, TEXT("Grab action is released!"));
	if (PhysicsHandle)
	{
		PhysicsHandle->ReleaseComponent();
	}
}

 

[展开全文]

授课教师

SiKi学院老师

课程特色

图文(2)
视频(37)