Download

Unable to move the Camera using SetWordLocation()

I’m having problems moving the camera. I have created an actor class and made a camera component which I have set as the root component. Now inside of my tick function, I’m trying to move the camera using the following code:


void ATheCamera::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	FVector NewLoc = GetActorLocation() + FVector(5, 0, 0);
	SetActorLocation(NewLoc, false);

}

Except the camera doesn’t move at all. I am setting the game’s camera to the current camera in the Level blueprint like this:

829c74e532982214f2b318697e6c54359c499629.png

Am I using the wrong code to move the camera?

Are you sure the tick is even being called? By default newly created actors don’t tick for performance reasons. Try putting this in the constructor:



PrimaryActorTick.bCanEverTick = true;


Also, drop a GEngine->AddOnScreenDebugMessage in the tick to make sure it’s actually working.

Wow thanks, that was the problem. Since I had a new constructor, the tick bool wasn’t in there.