Camera Boom, there is no Get World Location C++

Hello everyone, I am new to Unreal, recently I have made some improvements to character in third person template with blueprints, what i did was we can zoom in, zoom out, press F to change camera to shoulder to shoulder, shoot projectiles, rotate some skeletal mesh vs. Now, i am trying to achieve my character by not using blueprints but using C++. And I am stuck at very beginning :D. I was able to create a smooth translation for zooming by adding & substracting some values through Tick event, to / from Camera Boom’s target arm length. Now I am trying to make camera boom move to a little right & left if player presses F button, to make player be able to change shoulder in third person game. When I used blueprints, what i did was when player presses button, open a gate which Tick enters, and then use Set World Location, using VInterpTo. In VInterp parameters, I was able to set current location as CameraBoom ( take out a pin ) Get World Location and then same for target point. But in C++ i got stuck here, in visual studio when I do this :

CameraBoom->GetWorldLocation 

nothing pops up, there is RelativeLocation, there is SetRelativeLocation, there is SetWorldLocation, but not GetWorldLocation or WorldLocation

I don’t know what to do, if I try doing it using relative location, it only translates when mouse is been hovered by player ( don’t know why ) So I need a little help here.

CameraBoom->SetWorldLocation(FVector(CameraBoom->RelativeLocation.X, FMath::FInterpTo(CameraBoom->RelativeLocation.Y, originalY - 65.0f, deltaTime, shoulderChangeSpeed),CameraBoom->RelativeLocation.Z), false); 

// still can't do it if I use SetRelativeLocation

Why can’t I use GetWorldLocation in C++, what is the best way to translate camera boom smoothly, if it was for zooming i know i would use targetarmlength which i did, but now I am trying to translate it sideways with smooth motion. Can you help out ? Thanks in advance :slight_smile:

1 Like

You have GetComponentLocation which tells you the world position of the Camera Boom :slight_smile:

1 Like

oh yeah how could i miss that one, now i’m trying to implement my smooth transition by using world location, still not successful, any alternative ideas to move camera boom ? :frowning:

Edit: nevermind i achieved it, posting how i did it below, thanks for helping out :slight_smile:

Well i did what i wanted, just to help if anyones has the same question about how to move camera boom, i’m explaning what i did to achieve smooth transition.

First, I added 2 Child Actors in MyCharacter Blueprint, and selected them as TargetPoint. One is over right shoulder, the other one is over left shoulder. ( camera is set up in right shoulder in start )

This is what i used with comments;

            void ACTPCharacter::Tick(float DeltaSeconds)
            {
            	Super::Tick(DeltaSeconds);
            	
            	float deltaTime = GetWorld()->GetDeltaSeconds(); // get world delta secs
            
            // here 2 lines, they are important, as i searched i learned that, 
         //TArray<UChildActorComponent*> name, creates an array with name, and
             // this->GetComponents(arrayname) is used to put the
        // components inside your actor to the array i beleive, correct me if im wrong guys
            	TArray<UChildActorComponent*> MyActor_Children; 
            	this->GetComponents(MyActor_Children);
            
            	for (int i = 0; i < MyActor_Children.Num(); ++i)  // we open array
            	{
            
            	if (zoomBoolean)  // this part is to set camera zoom in&out smoothly
            	{
            		if (CameraBoom->TargetArmLength > minArmLength)
            			CameraBoom->TargetArmLength -= zoomRate;
            
            
                    }
            	if (zoomBoolean == false)
            	{
            		if (CameraBoom->TargetArmLength < maxArmLength)
            			CameraBoom->TargetArmLength += zoomRate;
            	}
            
            // when we press F, we call a function and inside that 
        //function i wrote bChangeShoulder = !bChangeShoulder, 
        //so everytime when I press F, it is true, and then false, true and then false ...
            		if (bChangeShoulder)  
            		{ 
CameraBoom->SetWorldLocation(FMath::VInterpTo(CameraBoom->GetComponentLocation(), 
MyActor_Children[1]->GetComponentLocation(), deltaTime, shoulderChangeSpeed), false);  
        // set world location of the camera boom to a point 
        //which is translated smoothly between camera boom's 
        //position( get component loc ) and second element of array, 
        // which is target point2 ( the one on the left shoulder )
            		}
            		else{
    CameraBoom->SetWorldLocation(FMath::VInterpTo(CameraBoom->GetComponentLocation(), MyActor_Children[0]->GetComponentLocation(), deltaTime, shoulderChangeSpeed), false);
            // do the opposite and translate camera boom back to right shoulder
            		}
            
            	}
            
            }

You’re welcome :slight_smile: