Strange behaviour in C++ Timeline Component Callback function

void ASYST_Character::TimelineProgress_CamFwd(float Value)
{

	

	UE_LOG(LogTemp, Warning, TEXT("Camera.Y & Z: %f, %f"), FirstPersonCameraComponent->GetComponentLocation().Y, FirstPersonCameraComponent->GetComponentLocation().Z);


}

In my timeline’s ‘FInterpFloat’ callback function, I want to print the values of my firstpersoncamercomponent’s world location.Y & Z

The timeline runs for a second and then reverses, so it is running all the time

I also have a seperate timeline that is rotating my character root back and forth constantly

because my character is being rotated constantly, i would expect the output of
my ‘UE_LOG’ to show constantly changing world location values for the camera, however this is not the case

the output shows the same, unchanging results, apart from 2 values being different at the very start, but after that it’s the same for the rest of play-in-editor
e.g.

LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.641848
LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.641848
LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.999863
LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.999863
LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.999863
LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.999863
LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.999863
LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.999863
LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.999863
LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.999863
LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.999863
LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.999863
LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.999863
LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.999863
LogTemp: Warning: Camera.Y & Z: 1731.999840, 665.999863


}

I wanted to prove to myself that ‘FirstPersonCameraComponent->GetComponentLocation().Z & Y’ was actually working and retrieving the world location so i wrote this same UE_LOG In ‘Tick()’ and it printed out the expected correct result, a constant changing list of world locations as my character’s rootcomponent rotated back & forth

E.G.

void ASYST_Character::Tick(float DeltaSeconds)
{
	UE_LOG(LogTemp, Warning, TEXT("Camera.Y & Z: %f, %f"), CameraComponent2->GetComponentLocation().Y, CameraComponent2->GetComponentLocation().Z);

}


}
LogTemp: Warning: Camera.Y & Z: 1731.999840, 680.601726
LogTemp: Warning: Camera.Y & Z: 1731.999840, 681.323940
LogTemp: Warning: Camera.Y & Z: 1731.999840, 682.003859
LogTemp: Warning: Camera.Y & Z: 1731.999840, 682.686766
LogTemp: Warning: Camera.Y & Z: 1731.999840, 683.363140
LogTemp: Warning: Camera.Y & Z: 1731.999840, 683.995927
LogTemp: Warning: Camera.Y & Z: 1731.999840, 684.680447
LogTemp: Warning: Camera.Y & Z: 1731.999840, 685.380125
LogTemp: Warning: Camera.Y & Z: 1731.999840, 685.930677
LogTemp: Warning: Camera.Y & Z: 1731.999840, 686.482763
LogTemp: Warning: Camera.Y & Z: 1731.999840, 687.038176
LogTemp: Warning: Camera.Y & Z: 1731.999840, 687.596829
LogTemp: Warning: Camera.Y & Z: 1731.999840, 688.158648
LogTemp: Warning: Camera.Y & Z: 1731.999840, 688.723569
LogTemp: Warning: Camera.Y & Z: 1731.999840, 689.291496

What could be happening here? Why isn’t my timeline callback function not printing the correct worldlocation of my first person camera component when it is obviously printing multiple times a second?

Thank you in advance

I fixed the issue (although I’m not sure exactly what did it as I cant seem to replicate the issue now)

Basically I used the timeline functionality via a ‘FTimeline’ instead of a UTimelineComponent

And I manually called FTimeline::TickTimeline(DeltaSeconds) Via the code below:

void ASYST_Character::Tick(float DeltaSeconds)
{
	
	CamFwdTimeline.TickTimeline(DeltaSeconds);

And finally I included this line

CamFwdTimeline.SetTimelineLength(2.0f);

This combination did the trick

The reason I am unsure on what exactly fixed it is because I just noticed it working when debugging, and then when I tried to retrace my steps to recreate the exact issue, I couldn’t and instead created other issues.

Hope this helps someone, I was going crazy with this one

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.