x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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 :)

Product Version: Not Selected
Tags:
more ▼

asked Oct 25 '14 at 03:17 PM in C++ Programming

avatar image

thistwp
33 1 2 20

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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

more ▼

answered Oct 25 '14 at 05:55 PM

avatar image

xlar8or
6k 161 129 304

avatar image thistwp Oct 25 '14 at 09:35 PM

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 ? :(

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

avatar image xlar8or Oct 26 '14 at 02:47 AM

You're welcome :-)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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
                     }
             
                 }
             
             }















more ▼

answered Oct 25 '14 at 10:22 PM

avatar image

thistwp
33 1 2 20

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question