Download

3D Top Down Shooter - Line Trace

Hey,

Im working on a small top down shooter/survival game, im in the very early stages.

Ive currently got the character moving around and animated without any issues, my issue is the shooting BP.
I know what ive done wrong, i just dont know how to fix it.

Currently im getting the line trace to start form the camera so the projectile shoots from the camera down to the center of the screen.

How would i go about doing a line trace from the weapon instead? Or is there a better way to work around shooting in a top down game?

Heres a screenshot of my BP:

Here is what i see in game from the line trace (its straight down from the camera)
CameraTrace.jpg

Thanks all :smiley:

See if there is bone on weapon that is around muzzle. If not add one yourself. Then place arrow component on it, facing forward from weapon.
Now instead of camera location and camera forward vector, you use arrow location and vector.
Later you can use that so spawn particle effects.

Yeah i managed to get the arrow working but for some reason it doesnt shoot in a straight line, it moves with the animations.
If that makes sense?
Is it possible to get the line trace to be a straight line regardless of the animation that is playing? Or would the “spread” from the animation make it look more natural?

ArrowComponent.png

Yes it will move with animations, because it is attached to gun that moves.
You need add aiming animation. Use aim offset, calculate values and then adjust gun to aim at cursor. Doable and looks really nice.

As its a top down game would aim offset be the best thing to use?
or do you mean using aim offset to look left and right?

I created something like that for top down and 3rd person game i was making. It works perfectly fine for topdown.
When you make weapon ready, you turn character towards cursor/aiming then you use aim offset for gun to perfectly aim. Looks really nice. Some trigonometry math needed.
When you move around character just holds gun lowered.

Sadly that was done around 4.3 i never updated it , and code does not work anymore. Some broken links beetwen nodes, finding what was connected where in such old project is pain in da …

That does sound interesting
Will add it to the list of potential additions to the project.

Thank you very much for the help :smiley: