Simple line trace weapon problem in BP

Hi All,

I have created a weapon blueprint using blueprint.
The custom event i created work but the line trace fires in other direction then where i look.
Here is an example and the blueprint i use. In the green circle you can see it fires to the right, when i turn 180 degrees it fires left.

I use this BP

I dont know what im diong wrong.

If someone can help me that would be great

Ah :smiley:

Easy mistake to make. Don’t multiply the vector. Add it. You have the location of your weapon socket. You calculated the trace (forward 5000 units) but now you have to add it to extend it on top of the location. Multiply will multiply each value in this vector (which exists of 3 floats) by the one of the other vector.

So yea. Just search for + and you should be fine :wink:

Cheers

Thanks for answering man, really nice of you :slight_smile:

Can you please give me an example, cause im a real noob if it comes to mathmatics and unreal.

If you could do that you will make my day.

There’s honestly not a lot to it.

Just replace the multiplication node ( x ) after the multiplication with the float and the forward vector with an addition one.

Like this:

You can do that by simply pulling out a wire from the vector pin and searching for “+”.

Cheers.

Thanks for the comments dude

Here is my setup of thw blueprint again.
I did what you said but im still firing sideways.

Here is the blueprint

I really dont know whats happening anymore :S

Well this already looks better.

Now have you checked what “Forward Vector” provides you with in the rifle BP?

Maybe get the owning character and use it’s forward vector for testing?

Hi there,
Thanks again, I copied the bp components to my character and now it fires the correct direction!
But the only problem that i fires the right direction im looking but not up of down.

Bp incoming:

Well that’s due to the way you use the “Get Forward Vector”. This provides you with the forward vector of your actor (character in this case). It doesn’t change with where you look. You can get the camera and use it’s forward vector to always have the exact middle of the screen. It will shoot slightly below where you’re looking (by the amount of units your gun is actually below your camera) but in the right direction.