hey guys I am switching my nodes into c++. I need to set this variable (called from the player controller) from this actor bp. How can I do this in c++? Do I have to cast? Thanks guyssss
So if I understand this correctly, âRespawnTimesâ is an int in your custom player controller. âAddâ is an int in this actor, and thatâs the amount you want to set âRespawnTimesâ to be. You should rename âAddâ to something more reasonable though.
// Get the local player's player controller.
APlayerController* LocalPlayerController = GetWorld()->GetFirstPlayerController();
if (LocalPlayerController)
{
// If the local player controller is not null, cast it to our custom player controller class.
AMyCustomPlayerController* MyCustomPlayerController = Cast<AMyCustomPlayerController>(LocalPlayerController);
if (MyCustomPlayerController)
{
// If the cast was succcessful, set the variable.
MyCustomPlayerController->RespawnTimes = Add;
}
}
Cool thanks a lot dude!!! Yes I was just posting an example with a random variable name, it was more to understand how should I work on these kind of situations Thanks for your help I really appreciate