GetComponentLocation() not found

I am trying like this:

FVector start = GetComponentLocation();

But I get this error:

‘GetComponentLocation’: identifier not found

I included #include "Components/SceneComponent.h" but same error

This file is Character main class , any ideas ?
ACryptRaiderCharacter::ACryptRaiderCharacter()

Hi william5642,

GetComponentLocation is for components - try GetActorLocation

1 Like

Now I get error GetForwardVector': identifier not found in

FVector end = start + GetForwardVector() * MaxGrabDistance;

Yes, try GetActorForwardVector instead - most of the functions around location etc are GetActor…

1 Like

Many Thanks :sunflower:

1 Like

Hi

Another problem when I try to use GetPhysicsHandle() it become nullptr. How to get the PhysicsHandle from actor ?

void ACryptRaiderCharacter::GrabFunc(const FInputActionValue& Value)
{
	UPhysicsHandleComponent* PhysicsHandle = GetPhysicsHandle();
	if (PhysicsHandle == nullptr)
	{
		UE_LOG(LogTemp, Warning, TEXT("No physics handle"));
		return;
	}

display “No physics handle”

That should give you an error - what you need to do is add a physics handle component:
image

1 Like