Enemy Continues Shooting?

Hi all,

So, I added the following lines to my code:

if (isDead() == true) {
		//if enemy is dead stop firing
		DetachFromControllerPendingDestroy();
		GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision);
	}

Yes, I realise the “==true” is not needed, but, I add it for clarity - it just helps when reading through code, especially at a later date. But anyway the code is still allowing for the enemy to fire whilst lying on the floor into the wild blue yonder(ie the direction at which the gun is pointing after falling over). I have made some minor changes to the code to allow the fire button to be able to be held down to fire a burst of x amount of rounds quickly, then force a reload for x amount of time. This also overrides the wait time in the behaviour tree, so would this be the culprit in the continual firing? Or should the “DetachFromControllerPendingDestroy()” stop this action from ocurring?

All help is greatly appreciated.

I am half convinced that another blueprint class based off the shooter class - without the extra functionality of shooting in bursts would work - but, I don’t know whether the extra work would be worth it. There should be an easy wat to shut down the shooting, even with those couple of lines I added, but, I can’t find it!

So to be clear the dead, on the floor, characters are shooting?

YES! That is exactly what is happening.

I found a solution to the problem of the enemy continually firing after falling over with no health - ie dead.

It was because of the extra functionality of burst or single fire that I implemented from a post from a former student where the system was setup using timers without accounting for the fact that “death” could occur and it also overwrites the behaviour tree where the “enemy” is supposed to wait x seconds before firing. The first part of the solution stopped the appearance of a shot occurring but was still continually trying to run the code, the second step was stopping (clearing) the timer.

I still haven’t set it up properly to see what happen if the burst fire was really quick I was happy to keep it rather slow and steady for testing, but, it might make the enemy fire extremely quickly as well, meaning the player has no chance of surviving, if that is the case the burst fire might have to go bye-bye for now and then try and implement secondary blueprints for - different - enemy character(s) which I have been a little concerned about not being implemented for some time now, at a later date. Should I not be able do that myself, that is where Stephen Ulibarri course will come into play. I fully understand if that last sentence needs to edited out by the moderator.

Regards.

Yep ,sure enough, the “enemy” character now has burst firing all the time :unamused:. So it has to go bye-bye now.

The thing is it looked great with the “hero” character. Oh well, back to spamming the Left Mouse Button. Back to stock now.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms