x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to fire projectile from skeletal mesh socket to crosshair in third person?

I have been using the third person template so far, and I'm trying to get the player to shoot at the mouse location. Think of any third person/over the shoulder games where the player can fire weapons (Last of Us, Watch Dogs, Infamous, etc). I'm close, but the aim is off by a bit. Here's what I've done so far:

  • I'm using Owen from the content examples (the one where you possess him) but in a third person template. I imported that pawn and am using him instead of the blue-ish mannequin guy.

  • I am using the LeftHandSocket as the projectile spawn point in Owen's skeletal mesh.

  • Projectile velocity is x = 1, y = 0, z = 0 with no gravity.

  • Crosshair at center of viewport.

I spawn the projectile by left clicking in the character blueprint at the socket's location + a forward vector and at the rotation of Get Control Rotation node. The projectile is will travel in the same relative direction the camera is facing, and hit somewhat close to whatever the crosshair is pointing at but a little to the left. I feel like I'm missing something simple, but I've watched all of the tutorials I can find. I've looked at all of the sample projects like the Shooter Game, but that's in c++. I'm doing this in blueprint only.

I hope someone can point me in the right direction.

Product Version: Not Selected
Tags:
more ▼

asked Jul 06 '14 at 07:30 AM in Blueprint Scripting

avatar image

cyborgjynx
30 3 4 9

avatar image ThierryH Jan 09 '15 at 11:32 AM

Hello, ca you help me by uploading a larger image, please.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

There is also a get socket transform function that allows you to choose what socket you want to spawn from :)

more ▼

answered Jan 18 '15 at 06:29 AM

avatar image

Tone
26 2 3 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I made some headway and think I have it figured out. If there's an easier way or more efficient way, please post it!

I did all of this in the Third Person Template, but I used Owen from the content examples (I migrated him from Content Examples). It would probably work with the default mannequin guy as well, but I haven't tested that. Here's what I did (sorry if it's grainy):

alt text

The event to in the image is just the Left Mouse Button (I have it set in the project setting's input panel as shoot). The projectile I have set up is the same from the first person shooter template (velocity only in X direction, initial speed of 2000, but with no gravity so it will fly straight).

Basically, you have to do a trace from mouse world location to 20000 units forward. That 20000 may be way too big, but it will ensure the trace hits something. If the trace hits nothing, the projectile will fire at the last item that was hit. Then using the location from the break hit result, find the look at rotation between spawn point of projectile and this hit location. I have my crosshair in middle of the screen by the way.

When you spawn the projectile, the location is the your spawn location you need to set up before hand and the rotation is the result of the find look at rotation node. For the spawn position, I spawned my projectile at the desired location * 100 units forward. My spawn position is Owen's RightHandSocket. Note that the 100 forward is not simply 100 units in x world location, but 100 units forward from whatever direction you are facing.

To actually see the line trace, select an option from the drop down box in the Single Line Trace by Channel node.

I hope this helps someone!

more ▼

answered Jul 06 '14 at 09:57 PM

avatar image

cyborgjynx
30 3 4 9

avatar image RedLine Nov 23 '14 at 09:58 PM

This interests me! Is there a way you could upload a sharper/larger image? it's just to grainy for me to make out. Cheers!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question