Download

Spring arm offset and timeline issue

Hi, hoping someone can help with an issue that I’m totally stumped on. I first have decided to limit the camera to the X axis in a 2D sidescroller by adjusting the target offset using this code:



void AMyChar::LimitCameraX()
{
	float CameraHeight = 110.0f;
	FVector Offset; 
	Offset = GetCapsuleComponent()->GetComponentLocation();

	Offset.X = 0.0f;
	Offset.Y = 0.0f;

	Offset.Z = CameraHeight -= Offset.Z;

	GetCameraBoom()->TargetOffset = Offset;
}

It runs on event tick and works perfectly. However I then started using a simple timeline that just sets the player’s location to a few units above them so they rise slowly over the duration of 1 second. But when the timeline starts, there is a noticeable jerk with the camera. Its almost as if both my limit camera function and the timeline cannot both operate on the first frame the timeline starts. It works fine when I jump, fall, launch character etc. however. I need to use a timeline as I want to move the character smoothly and slowly.

I have tried running my limit camera function only when timeline is not playing and then running it separately in my timeline’s update function but this doesn’t work. I have also tried set component location rather than actor in my timeline in case there was some discrepancy but that isn’t the issue either.

If anyone knows what’s happening or can lend advice it would be greatly appreciated.

Thanks, Mark