Projectile Disappearing Instantly When Fired

Hey!

I’m following this tutorial to learn the basics of making a top down shooter. It’s my first time using blueprints, and everything was going well until I started trying to make a laser projectile I built hit my enemy.

Here’s the blueprint for the laser

So as you can see, it has scripting for overlap. It’s supposed to check that it’s not hitting the player character before decrementing health, as it has a weird issue with hitting the PC (is that common?)

I’ve put print string at several intervals to test what’s happening when the PC fires the laser projectile, and it’s failing every time. I even ran the laser in Simulation and it disappears instead of going one way or another as it usually would.

Here’s an image of the laser consistently failing to cast

Here’s a detail of the print screen messages:
image

Sorry if this message needs more information, let me know if you need to see more to help me.

Thanks in advance!

Hey @sh8dyw8yz! Welcome to the forum!

Try checking your hit actor with a get class off the hit actor, and doing an = check against a parent class, like third person character. Otherwise, if they’re not compatible the cast will fail. So if it hits the ground? Fail cast. :slight_smile:

1 Like

Thank you for your reply!

This idea (as I understood it) worked mostly! Before I linked the get actor node to the “Cast to AI_Enemy” node, the laser began firing again. Did I arrange this properly?

Thanks again, I really appreciate the help.

Hello.

What is BP_Laser? Is it a weapon or projectile?
What is BP_ThirdPersonCharecter? Is it AI or Player?
Show us the code for spawning the projectile.

Hello!

BP_Laser is a projectile. BP_ThirdPersonCharacter is the player character in this game and AI_Enemy is the enemy that you can see closer to the top of the screen.

Sorry for not posting this initially, here’s the blueprint for firing that’s triggered on BP_ThirdPersonCharacter:

The projectile spawner is an arrow in front of the character that spawns the BP_Laser when the LMB is clicked.

Thank you!

Here is your problem. So, going from your prints projectile is overlapping with itself. You do have check for player, but not for itself. It passes first if node, goes to cast, fails and destroys itself.
Check your laser components for collisions. Make them stop overlapping themselves.

1 Like

Solved it with another not equal check on a self-reference. Thank you!

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