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"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

How to get current "Target Arm Length" of camera spring arm in Third Person Blueprint Template?

Hello,

In UE4 Third Person Blueprint Template, I am trying to get the value of Camera Boom's Target Arm Length.

Using the very simple BP below, I am printing the value on screen at every tick.

alt text

Problem: When the Camera Boom collides with any object in scene, camera zoom in/out to the character just as expected. But, the value of Target Arm Length somehow never changes!

Question: Is this normal? If yes, what parameter should I check for getting the distance between Camera Boom and the character?

Product Version: Not Selected
Tags:
simplebp.png (1.1 MB)
more ▼

asked Oct 06 '14 at 05:08 PM in Blueprint Scripting

avatar image

Dynamo
92 9 16 18

avatar image Dynamo Oct 06 '14 at 05:16 PM
(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

Hi,

from my undestanding the code, the Target Arm Length always remain the same, but take a look on the:

 void USpringArmComponent::UpdateDesiredArmLocation(bool bDoTrace, bool bDoLocationLag, bool bDoRotationLag, float DeltaTime)


This function updates protected members (RelativeSocketLocation, RelativeSocketRotation) of spring arm component:

// Form a transform for new world transform for camera FTransform WorldCamTM(DesiredRot, ResultLoc); // Convert to relative to component FTransform RelCamTM = WorldCamTM.GetRelativeTransform(ComponentToWorld);

 // Update socket location/rotation
 RelativeSocketLocation = RelCamTM.GetLocation();
 RelativeSocketRotation = RelCamTM.GetRotation();

 UpdateChildTransforms();



And they are exposed in BP with "GetSocketTransform" function. You can try call "GetSocketTransform" with RTS_Component parameter and obtain position then compute length of this vector.

 FTransform USpringArmComponent::GetSocketTransform(FName InSocketName, ERelativeTransformSpace TransformSpace) const
 {
     FTransform RelativeTransform(RelativeSocketRotation, RelativeSocketLocation);
 
     switch(TransformSpace)
     {
         case RTS_World:
         {
             return RelativeTransform * ComponentToWorld;
             break;
         }
         case RTS_Actor:
         {
             if( const AActor* Actor = GetOwner() )
             {
                 FTransform SocketTransform = RelativeTransform * ComponentToWorld;
                 return SocketTransform.GetRelativeTransform(Actor->GetTransform());
             }
             break;
         }
         case RTS_Component:
         {
             return RelativeTransform;
         }
     }
     return RelativeTransform;
 }



Regards

Pierdek

more ▼

answered Oct 06 '14 at 07:24 PM

avatar image

Pierdek
2.6k 73 49 131

avatar image Dynamo Oct 06 '14 at 08:08 PM

Great idea!

Thank you very much Pierdek.

It works :-)

ps: Would you please convert your reply into an answer, so that I can click the checkmark to mark your answer accepted?

avatar image MeshMyster Dec 14 '15 at 12:30 AM

Can you add a blueprint function that returns the current length of the spring arm when it's being pushed?

(comments are locked)
10|2000 characters needed characters left

Here's a way using blueprints. You could probably use a property of the SpringArm itself (instead of "Sphere") to make this more portable.

here's another way, using blueprints

more ▼

answered May 28 '16 at 02:59 AM

avatar image

MattWoelk
32 4 6

avatar image NamInUz Jul 19 '17 at 05:58 PM

and you can use length squared to optimize it

(comments are locked)
10|2000 characters needed characters left
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