Firing does not work

Could some one please explain how the video is showing the BP_Character firing? In the lecture, we delete the Fire BP function and then we create:

void AMannequin::Fire()

No where in the C++ code is that method called… so how is this being called in the video? Also, in the lecture we deleted all the TP components. The behavior I am seeing is as follows:
BeginPlay, Gun is visible but unable to fire. AI Gun spawns with AM_FPFire Fire Animation and ABP_FP_C_1 Anim Instance.

The behavior I am seeing is 100% expected but for whatever reason the lecture video shows things working when I do not see how it could possibly be working. Can anyone explain this or is the video misleading and they are not running the same code that is in the lecture? Thank you.

EDIT: The gun spawns w/ FP animations, while the BP_Character spawns w/ ABP_TP, which seems correct.

This still confuses me, and my firing isn’t working… Where is fire being called?

I think fire is still being called from the animation blueprint. AnimNotify_Fire–>Cast To BP_Character–>Fire… It still seems like the animation is driving the firing behaviour lol…

My firing does not function as well after completing this lecture. (v. 4.19)…

That is correct, the fire method from the mannequin is being called by the animation_notify

  1. The input is caught here

  2. It then gets bound here

  3. The firing animation plays which triggers this

  4. The rest is handled by the following code in the gun.cpp

void AGun::OnFire()
	// try and fire a projectile
	if (ProjectileClass != NULL)
		UWorld* const World = GetWorld();
		if (World != NULL)

			const FRotator SpawnRotation = FP_MuzzleLocation->GetComponentRotation();
			// MuzzleOffset is in camera space, so transform it to world space before offsetting from the character location to find the final muzzle position
			const FVector SpawnLocation =  FP_MuzzleLocation->GetComponentLocation();

			//Set Spawn Collision Handling Override
			FActorSpawnParameters ActorSpawnParams;
			ActorSpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButDontSpawnIfColliding;

			// spawn the projectile at the muzzle
			World->SpawnActor<ABallProjectile>(ProjectileClass, SpawnLocation, SpawnRotation, ActorSpawnParams);

			//UE_LOG(LogTemp, Warning, TEXT("Fire"));

	// try and play the sound if specified
	if (FireSound != NULL)
		UGameplayStatics::PlaySoundAtLocation(this, FireSound, GetActorLocation());

	// try and play a firing animation if specified
	if (FireAnimation != NULL)
		// Get the animation object for the arms mesh
		if (AnimInstance != NULL)
			AnimInstance->Montage_Play(FireAnimation, 1.f);

Privacy & Terms