This is code that I'm using for a ammo pickup, the problem is when i walk over the sphere component unreal crashes. I have narrowed the problem down to these two lines (commented) but i don't know how i would fix this. Another problem of mine is what do i put in my second cast statement to make this work?
void AAmmoPack::NotifyActorBeginOverlap(AActor* OtherActor)
{
Super::NotifyActorBeginOverlap(OtherActor);
ASCharacter* MyCharacter = Cast<ASCharacter>(OtherActor);
if (MyCharacter) {
//ASWeapon* Weapon = Cast<ASWeapon>();
//Destroy();
}
}
Well, you're trying to cast void to ASWeapon.
In your code ASWeapon* Weapon = Cast<ASWeapon>( /*HERE SHOULD BE OBJECT YOU CAST TO WEAPON*/ );