How can I spawn a bullet at the tip of the rifle?

I’m developing a top down shooter, I bought some assets, and downloaded some mixamo animations, and they’re working almost perfectly (this is a separate issue I can fix later), I’ve added a rifle to the right hand of the character, and what I want is for the rifle to spawn a projectile at the very tip of barrel, I’ve managed to accomplish this but since I’m using the actor transform, and trying to move the spawn location from the root of the rifle to the tip manually, it only fires in the correct direction at spawn, if I move the character the location and rotation get all messed up.

I’m pretty sure I should be using relative values to the root of the rifle in the world, but I’m not sure how to do this in blueprints.

I’ll attach a screenshot of the blueprint and of the behavior because I can’t upload videos:

Screenshot 2024-02-27 095648
Screenshot 2024-02-27 095657
Screenshot 2024-02-27 095703
Screenshot 2024-02-27 095707

You can add a socket to your rifle static mesh and position it at the tip of the barrel in the Static Mesh viewer. Then, when you want to spawn your bullet, get a reference to your rifle mesh and then use Get Socket Transform to get the world space location and rotation where you want to spawn your VFX.

Would I have to do this for each skeletal mesh or can it be done in the blueprint?

You’ll want to setup the socket per mesh, that way you can position them appropriately for any weapon types (ie: Rifle, Shotgun, Pistol, Bazooka, etc.). But, if you name the socket the same for each mesh, then you can use a mesh variable with the current weapon assigned to it and use the same blueprint logic to get the socket transform regardless of which weapon is equipped.

In case it helps anyone in the future, I had to drag the weapon skeleton from the components to the event graph (I imagine because the character owns that skeleton or it is the parent of it), from there I could get the GetSocket Transform and it worked. I’ll attach a screenshot:

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