C++ & BP sense combination

ok I tried going the C++ route, and for particle effects, emitting sound and making AI aware of a sound being emitted and it does work.

First step was to add

`

	if (ProjectileImpactEffect)
	{
		UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ProjectileImpactEffect, GetActorLocation());
		if (ProjectileImpactSound)
		{
			UGameplayStatics::PlaySoundAtLocation(this, ProjectileImpactSound, GetActorLocation());
			UAISense_Hearing::ReportNoiseEvent(GetWorld(), GetActorLocation());
		}

into the TestingGroundsProjectile.cpp “OnHit()” function conveniently there already for when the projectile hits bodies that simulate physics to indicate impact and to Report Noise events.

Added UAISense_Hearing::ReportNoiseEvent(GetWorld(), GetActorLocation(), 1.0f, this); to the first person character as well to indicate that he makes noise when he fires his weapon.

I tried registering the projectile as it exploded on impact, but I found out that the AI sensing works on pawns and that detecting a name of an actor (projectile) is a thing you’d do by using environment query system or EQS if I’m right and I think I’ll leave it for now :slight_smile: Found the info on that here.

In the end it turns out like this :slight_smile:

1 Like

Awesome work! I find this really helpful!

1 Like

Glad it helps :slight_smile:

1 Like

Privacy & Terms