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?
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);
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.
There’s no way to get the current length of the Spring Arm. The Target Arm Length is exactly what it sounds like “A Target” so this value is unchanging when the spring arm is collapsed or not. The best you can do is get the distance between your mesh and the camera itself and if its vector length is lower than X value, then you can do whatever you want.
For example, I run this on tick to check if my camera is close to the player, and if it is, I dissolve the mesh:
Additionally, you can test to see if the collision fix is being applied. This means while you can’t know the length of the Spring Arm, you can know if it is collapsed.
This will become true when the camera is colliding with the world. You can use this to make sure that you’re only fading out your character mesh when the camera is colliding and the distance is shorter than X. You might want to allow the player to zoom in on the character when it’s not colliding for example.