I’m currently getting crashes whenever I fire my weapon at a BSP, I’m assuming the engine doesn’t like this as BSP cannot take damage maybe?
When I comment out my DealingDamage function then all is OK. So, how do I reference BSPs in C++?
Here’s my code:
void AQUBEWeapon::DealingDamage(uint8 FireModeNum, const FHitResult& Impact, const FVector& ShootDir)
{
FPointDamageEvent PointDmg;
PointDmg.DamageTypeClass = FireModes[FireModeNum].DamageType;
PointDmg.HitInfo = Impact;
PointDmg.ShotDirection = ShootDir;
PointDmg.Damage = FireModes[FireModeNum].HitDamage;
AQUBECharacterPlayer* CharacterPlayer = Cast(Instigator);
if (CharacterPlayer != NULL)
{
Impact.GetActor()->TakeDamage(PointDmg.Damage, PointDmg, CharacterPlayer->Controller, this);
if(DrawDebugs)
DrawDebugSphere(GetWorld(), Impact.Location, 10.f, 16, FColor(0,255,0), false, 3.f, 0);
// Spawning particle emitters is slow :/
// Let's spawn a debug sphere for now.
//SpawnImpactEffects(Impact);
DrawDebugSphere(GetWorld(), Impact.Location, 5.f, 30, FColor(155,195,255), false, 0.5f, 0);
UE_LOG( LogSomething, All, TEXT( "--- Calling QUBEWeapon -- Dealing Damage to Actor : %s" ), *Impact.GetActor()->GetName());
UE_LOG( LogSomething, All, TEXT( "--- Calling QUBEWeapon -- Damage Type Class : %s" ), *PointDmg.DamageTypeClass);
UE_LOG( LogSomething, All, TEXT( "--- Calling QUBEWeapon -- Damage Amount : %i" ), (int32)PointDmg.Damage);
}
}
Thanks!
Jon