I'll need quite some help polishing my game

Because of all of these…








These are incomplete.



As you can see from this:

Use Build instead of Build + Intellisense for the error list. Intellisense errors generate a lot of false positives.

  1. You need to include the headers for the types you are using.
  2. FRotator not VRotator

Progress report:





Any information regarding these?



(Oh yeah. I called my BuildingEscape Game “GetOuttaHereQuickly”)

  1. Missing ,
  2. Missing >
  3. You have two format specifiers but don’t have any format arguments
  4. Doesn’t look like an error, however the TArray should be declared on the line below since if the condition is true you just made a TArray for nothing.

I think I almost got it… But I am once again stumped. I got the rest of them done, but not yet this.

Whenever you access members of a type you will need to include the header for that type.

On that line what types are you accessing members of?

AActor. I will show you where I put in “GameFramework/Actor.h”.

That’s not the only type on that line, what are you calling GetMass from?

The mass of the actors on the TriggerVolume.

Sorry, I meant what type.

UPrimitiveComponent.

Did you include the header for that?

Aha! It worked! Now all I need to do is do all of that compiling… if I can resolve all of this.

You have quite a few errors in PositionReport.h and Grabber.cpp. Would need to see those files to be able to say what you did wrong.

Unfortunately, the problem is I would send it, but they say the file names aren’t authorized. Not even letting me publish my work of my Bull Cow Game.

Just post the code here and use a code block

```
int main()
{
}
```
Becomes

int main()
{
}

PositionReporter.h(Otherwise known as PositionReport.h)

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "PositionReporter.generated.h"

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class GETOUTTAHEREQUICKLY_API UPositionReporter : public UActorComponent
{
	GENERATED_BODY()

public:	
	UPositionReporter::UPositionReporter()
{
	bWantsBeginPlay = true;
	PrimaryComponentTick.bCanEverTick = true;
}

protected:
	virtual void BeginPlay() override {

	FString ObjectName = GetOwner()->GetName();
	FString ObjectPos = GetOwner()->GetTransform().GetLocation().ToString();
	UE_LOG(LogTemp, Warning, TEXT("%s is at %s")) 

	}

private:	
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

		
};

Grabber.cpp

#include "GetOuttaHereQuickly.h"
#include "Grabber.h"

#define OUT

// Sets default values for this component's properties
UGrabber::UGrabber()
{
	// Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	bWantsBeginPlay = true;
	PrimaryComponentTick.bCanEverTick = true;
}

// Called when the game starts
void UGrabber::BeginPlay()
{
	Super::BeginPlay();
	FindPhysicsHandleComponent();
	SetupInputComponent();
}

/// Look for attached Physics Handle
void UGrabber::FindPhysicsHandleComponent()
{
	PhysicsHandle = GetOwner()->FindComponentByClass<UPhysicsHandleComponent>;
	if (PhysicsHandle == nullptr)
	{
		UE_LOG(LogTemp, Error, TEXT("%s missing physics handle component"), *GetOwner()->GetName())
	}
};

void UGrabber::SetupInputComponent()
{
	InputComponent = GetOwner()->FindComponentByClass>UInputComponent();
	if (InputComponent)
	{
		InputComponent->BindAction("Grab", IE_Pressed, this, &UGrabber::Grab);
		InputComponent->BindAction("Grab", IE_Released, this, &UGrabber::Release);
	}
	else
	{
		UE_LOG(LogTemp, Error, TEXT("%s missing input component"), *GetOwner()->GetName());
	}
}

// Called every frame
void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	if (!PhysicsHandle) { return; }
	// if the physics handle is attached
	if (PhysicsHandle->GrabbedComponent)
	{
		// move the object that we're holding
		PhysicsHandle->SetTargetLocation(GetReachLineEnd());
	}
}

void UGrabber::Grab() {
	/// LINE TRACE and see if we can reach any actors with physics body collision channel set
	auto HitResult = GetFirstPhysicsBodyInReach();
	auto ComponentToGrab = HitResult.GetComponent(); // gets the mesh in our case
	auto ActorHit = HitResult.GetActor();

	/// If we hit something then attach a physics handle
	if (ActorHit)
	{
		if (!PhysicsHandle) { return; }
		PhysicsHandle->GrabComponent(
			ComponentToGrab,
			NAME_None, // No bones needed
			ComponentToGrab->GetOwner()->GetActorLocation(),
			true // allow rotation
		);
	}
}

void UGrabber::Release()
{
	if (!PhysicsHandle) { return; }
	PhysicsHandle->ReleaseComponent();
}

const FHitResult UGrabber::GetFirstPhysicsBodyInReach()
{
	/// Line-trace (AKA ray-cast) out to reach distance
	FHitResult HitResult;
	FCollisionQueryParams TraceParameters(FName(TEXT("")));
		false;
		GetOwner();
	GetWorld()->LineTraceSingleByObjectType(
		OUT HitResult,
		GetReachLineStart(),
		GetReachLineEnd(),
		FCollisionObjectQueryParams(ECollisionChannel::ECC_PhysicsBody),
		TraceParameters
	);
	return HitResult;
}

FVector UGrabber::GetReachLineStart()
{
	FVector PlayerViewPointLocation;
	FRotator PlayerViewPointRotation;
	GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(
		OUT PlayerViewPointLocation,
		OUT PlayerViewPointRotation
	);
	return PlayerViewPointLocation;
}

FVector UGrabber::GetReachLineEnd()
{
	FVector PlayerViewPointLocation;
	FRotator PlayerViewPointRotation;
	GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(
		OUT PlayerViewPointLocation,
		OUT PlayerViewPointRotation
	);
	return PlayerViewPointLocation + PlayerViewPointRotation.Vector() * Reach;
}

I’m with family this weekend so I’ll have to get back to you later. However, in the meantime could you put your code in a code block as described above?

- snip -

Not exactly since you have a lot of “copy to clipboard” lines. And I was actually suggesting you edit your previous comment.

Edit: I’ve now edited your posts.

The problem with PositionReporter.h is that you have code meant for the .cpp. There should only be declarations.

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "PositionReporter.generated.h"

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class GETOUTTAHEREQUICKLY_API UPositionReporter : public UActorComponent
{
	GENERATED_BODY()

public:	
	UPositionReporter::UPositionReporter();

protected:
	virtual void BeginPlay() override;

private:	
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

		
};

As for Grabber.cpp this is incorrect

FCollisionQueryParams TraceParameters(FName(TEXT("")));
		false;
		GetOwner();
	GetWorld()->LineTraceSingleByObjectType(
		OUT HitResult,
		GetReachLineStart(),
		GetReachLineEnd(),
		FCollisionObjectQueryParams(ECollisionChannel::ECC_PhysicsBody),
		TraceParameters
	);
	return HitResult;

It should be

FCollisionQueryParams TraceParameters(FName(TEXT("")), false, GetOwner());
GetWorld()->LineTraceSingleByObjectType(
	OUT HitResult,
	GetReachLineStart(),
	GetReachLineEnd(),
	FCollisionObjectQueryParams(ECollisionChannel::ECC_PhysicsBody),
	TraceParameters
);
return HitResult;

Privacy & Terms