Download

Destroying Actor when Shot with Line Trace

Heyo everyone. Long time lurker and first time poster - wonder if someone could put me out of my misery/help me.

I’ve used a couple of tutorials on Youtube to set up a simple character (from the Mixamo pack) to chase the main player around. I’ve also managed to set up a line trace for when you shoot with my gun to know that you’ve shot the character as well.

My two blueprints are attached and it calls on an event called “Die” to destroy the actor or simulate physics. Only thing is, it doesn’t. I’ve seen so many tutorials where they seem to do the same things I do but I’m just not getting it!

Treat me like an idiot because I think I am being.

Thanks in advance for any help at all.

Dave.

There are a few things that might be wrong and you have no debugging info in there to tell you what is broken.

Hook up a print string to the Cast Failed on the Cast to enemypc node so you can see if it’s failing.

Hook up a print string to the return value of the line trace to see if you are actually hitting anything valid.

In your die event add a print string before destroy see if its firing.

You can also use F9 to set breaks on nodes and it will pause during execution so you can see what is happening. I would put one on the Cast node to see if your out hit is actually anything at all. Same with the calling of the Die on the enemy so you can see if the cast worked properly.

Doing this you can break down where it is broken and then work on fixing it =)

Ah thank you! That’s a good start. It’s constantly saying it’s missing everytime with that print string attached to cast failed.

Not entirely sure why it’s doing that but it is a start!

Have you tried to ‘print’ your ‘Hit Actor’ Maybe it’s detecting a part of the enemynpc instead of the Blueprint itself?

And maybe try it without the input in ‘Object Types’ I’d try to limit is as little as possible and then work yourself up from there as soon as it works. It’s easier to fix it when you only added one thing and it suddenly stops working.

I’ve sorted it! Thank you both!

It turned out that I needed to reference my original object and not the blueprint class…no idea why but you both managed to steer me in the right direction.

Thanks again!

Is there any possible way to create multiple trace lines as if it was like a shotgun?