Where can I reference BSP in C++?

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

When a trace hits BSP the Component will be a ModelComponent, but the Actor will be NULL, which is why your code is crashing. BSP is rendered and collided as a series of ModelComponents owned by the level, but not by and particular Actor.

Thanks for the fast reply and the easy solution!

I have now added:

if(Impact.GetActor() != NULL)
{

}

And it’s working beautifully :smiley:

Thanks!

Jon