the error is "protected: void __cdecl AShooterCharacter::OnTime(void)" (?OnTime@AShooterCharacter@@IEAAXXZ) referenced in function "public: void __cdecl AShooterCharacter::GetTime(void)" (?GetTime@AShooterCharacter@@QEAAXXZ)
the error is ` "protected: void __cdecl AShooterCharacter::OnTime(void)" (?OnTime@AShooterCharacter@@IEAAXXZ) referenced in function "public: void __cdecl AShooterCharacter::GetTime(void)" (?GetTime@AShooterCharacter@@QEAAXXZ)
//this is in the header file
UFUNCTION()
void OnTime();
//this is making error
GetWorld()->GetTimerManager().SetTimer(JumpTime, this, &AShooterCharacter::OnTime, 0.f, false);
I think you are using timer wrong. Try something like this: GetWorld()->GetTimerManager().SetTimer(MyTimerHandle, this, &AShooterCharacter::OnTime, JumpTime, false, 0.0f)
and initialize MyTimerHandle like this FTimerHandle MyTimerHandle
before setting timer or better have a variable in your header file, so you could clear timer in any other function.
I initialize JumpTime as a FTimerHandle. I get 3 error messages and they are about OnTime function but i can’t find what i am doing wrong.
@Lawave527 Please check if your OnTime function is a UFUNCTION()
in you header file. If not, add UFUNCTION()
above. Keep me posted.
Yes it is in the header file and it is a UFunction.
I fixed it. It isn’t in the .cpp file it is just in the header file so it cannot make the connection with the function.
When you are binding to the function in C++, you always initialize your function, which will be called, with UFUNCTION()
. Glad, that helped. Please, mark as resolved