TargetArmLength from SpringArmComponent does not update correctly

Hey everyone,

I am trying to zoom in/out of my character via setting the TargetArmLength of the attached SpringArmComponent. Through play in editor I could confirm that the TargetArmLength is correctly set, though it does not change the view of the attached CameraComponent. If I set the TargetArmLength manually in play in editor though, it works.
Also my code used to work, but after working on some other classes, it suddenly does not anymore and I really can not work out why, because I have not made any changes to anything that would be connected to this.
I am using the 4.24 source build.

	if ((Controller != NULL) && (Value != 0.0f))
	{
		float Length = FMath::Clamp((Value + 1.0f) * CameraBoom->TargetArmLength, MinimalZoom, MaximalZoom);
		CameraBoom->TargetArmLength = FMath::FInterpTo(CameraBoom->TargetArmLength, Length, GetWorld()->GetDeltaSeconds(), 5.0f);

		float ZOffset = FMath::Clamp((Value + 2.5f) * CameraBoom->SocketOffset.Z, 0.0f, 40.0f);
		CameraBoom->SocketOffset.Z = FMath::FInterpTo(CameraBoom->SocketOffset.Z, ZOffset, GetWorld()->GetDeltaSeconds(), 20.0f);
	}

Thanks for any suggestions on how to fix this.

Hi LizLeyou

The logic seems fine. If it worked before and doesn’t now, then it seems like something interfering with this code.

  1. Make sure the function is actually getting called.

  2. If it is getting called and the data is set correctly. Make sure the camera component is attached to the spring arm. Perhaps something in the code is reparenting the camera somehow?

Also my code used to work, but after
working on some other classes, it
suddenly does not anymore and I really
can not work out why, because I have
not made any changes to anything that
would be connected to this

I have had many scenarios like this :smiley:

The next step would be to work backwards to see when this issue began. Issues like this demonstrate why source control is extremely important as it makes it easier to look back and revert code changes without damaging a project further.

If you are still struggling. I would implement your camera spring logic in a clean project to make sure it is absolutely 100% working then overwrite your current implementation with the clean one.

Unfortunately, there isn’t much more I can suggest.

Good luck!

Alex

I ended up removing the code and adding it again bit by bit, compiling after every bit to see if it still worked as intended. For some reason that worked ^^

I am glad you got it solved.

I have definitely had multiple experiences like this myself haha!.