One more question, this is a weird one.
If i have code that looks like this
void AFUOBVolume::ActorEnteredVolume(class AActor* Other)
{
UE_LOG(LogVolume, Log, TEXT("AFUOBVolume::ActorEnteredVolume %p is *Other"), Other);
UE_LOG(LogVolume, Log, TEXT("AFUOBVolume::ActorEnteredVolume %s is *Other"), *Other->GetName());
UE_LOG(LogVolume, Log, TEXT("AFUOBVolume::ActorEnteredVolume() = *Other = %s"), Other ? TEXT("TRUE") : TEXT("FALSE"));
AUnrealCharacter* const ToucherCharacter = Cast<AUnrealCharacter>(Other);//ARE WE A WALKER
UE_LOG(LogVolume, Log, TEXT("AFUOBVolume::ActorEnteredVolume %p is *ToucherCharacter"), ToucherCharacter);
UE_LOG(LogVolume, Log, TEXT("AFUOBVolume::ActorEnteredVolume %s is *ToucherCharacter"), *ToucherCharacter->GetName());
UE_LOG(LogVolume, Log, TEXT("AFUOBVolume::ActorEnteredVolume() = *ToucherCharacter = %s"), ToucherCharacter ? TEXT("TRUE") : TEXT("FALSE"));
//keep out projectiles
if(ToucherCharacter == nullptr)//TYPE_OF_NULLPTR
{
AUnrealVehicle* const ToucherVehicle = Cast<AUnrealVehicle>(Other);//ARE WE A VEHICLE
if((ToucherCharacter == nullptr) && (ToucherVehicle == nullptr))
return;
//have to use ToucherVehicle here or wont work out side if, wth?
}
//ToucherCharacter WILL WORK HERE AS IT WAS INTIATILIZED ABOVE THE IF STATEMENT. LIKE IT SHOULD ANY WHERE IN THIS FUNCTION
if (ToucherCharacter != nullptr)//true that we are in the volume//TYPE_OF_NULLPTR
{
ToucherCharacter->OBStartCountDown(killTime, true);
}
//TOUCHERVEHICLE WILL NOT WORK HERE AS IT WAS INTIATILIZED IN THE ABOVE IF STATEMENT, WHY? SHOULD IT NOT WORK ANYWHERE IN THIS FUNCTION?
if (ToucherVehicle != nullptr)//true that we are in the volume//TYPE_OF_NULLPTR
{
ToucherVehicle->OBStartCountDown(killTime, true);
}
}
ToucherVehicle > will not work in the last if statement. If i put the bottom if in the if (ToucherCharacter == nullptr) <it was set in(blue if), then it will work. Should it not work everywhere in that function as it was set in the function?
As if this go against the rule> if its defined and initialized in a function it can be used anywhere in that function?