Shooting a Weapon with Line Trace

Hello Guys

I tried to make gun and needed help.

I searched and found this post ( [click ][1]l )

I can’t really see much on the picture so I tried my best and know I’m stuck.

The Line Trace is working ( a litte bit off, but it’s working almost fine), but the projectile spawn is totally messed up.

They are flying backwards and spawning at my Mesh and I have no Idea why.

http://puu.sh/dPoax/6df3fbd078.jpg

  • Creey

Can you clarify what yor trying to do? Are you trying to spawn a mesh at a hit location ?

Seems simple. Your Look At Rotation has Start and Target twisted. It starts from the Hit Location (Where you bullet hits the wall/player or what ever) and it’s target is your Characters Forward Vector Multiplied by 100 + the Socket Location.

Look at the screen you posted from the other guy. The Hit Location is the Target (which makes scence) and the Start is that weird Position made up from your Forward Vector and the Socket Location. Otherwise it looks from the hitlocation at you and not from you to the hitlocation (:

Ohh ok that makes sense, tank you =)
But do you know why my Line Trace is a little bit to far on the top left?

Hm no, i guess because something is wrong with the Vectors you use. You start the line trace from the mouse position. So maybe the mouse is top left when you click. Have you tried just using the camera and character to line trace?

You could do something like that to let the linetrace begin at the center of the Camera:

http://puu.sh/dRVTp/76caf10e7b.png

Or you could also let it start at the weapon itself for more realism by using the Socket position.

For a more specific answer i would need to know what exactly you want to achieve (an ingame screenshot would be helpful ,because i don’t know if this is first person or third etc.)

It’s a third person shooter

Ok i will set something up tomorrow (:

Hello Creey,

When you say that your project is third person, do you mean:

  1. That it is an over the shoulder style game where the character never rotates separately from the camera
  2. It is an over the shoulder style game where the Character and the camera can be controlled separately (So that the view is not always behind the player)
  3. Is it a top down style shooter where the character rotates to follow the mouse?
  4. Is it a top down where the character is controlled through inputs in the keyboard/controller and the angle of fire has nothing to do with the position of the mouse?
  5. Is it a top down with a click to move system?
  6. Is it something else?

All of the above could be considered third person and an answer to this could help narrow down what sort of setup you will need to get a more accurate line trace.

Make it a great day

Hello Creey,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.

You control the movement with the keyboard and the crosshair (for shooting and attacking in general) with the mouse, the character always looks in the directions of the mouse. So it’s like number 1

(Sorry for the late response, were really busy)

Hello Creey,

If the cross hairs are in a fixed position you could use the “Convert screen location to world space” node and simply input the position of the cross hairs. If the cross hair’s position is determined by the mouse you can use the mouse position with the “Get mouse position” node and plug it’s X and Y positions into the “Convert screen location to world space” node. I hope this helps.

The following is an example of a line trace that shoots straight out from the position of the mouse.

Make it a great day

Thanks a lot, that helps =)