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 do I make my bullet go to my crosshair?

So, I have a Crosshair in the direct middle of my screen. I have a weapon set up that when I fire, it will use the spawn actor class node to spawn in the bullet. The only problem is, that the bullet goes where ever my gun is facing because the bullet is coming out of the socket. How would I make my bullet go to my crosshair? Would I have to use a line trace? How would I use a line trace? Help is appreciated! Thanks!

Product Version: UE 4.20
Tags:
more ▼

asked Nov 08 '18 at 05:15 AM in Blueprint Scripting

avatar image

CODE REDBALLG
115 2 7 17

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

1 answer: sort voted first

While you can draw a trace you don't need to in this case. Within the event tick set a custom variable "mouse location" by using:

'get player controller' -> 'get hit result under cursor by channel' -> 'break hit result' -> 'set'

You can now use the custom variable location along with the location of where the projectile is spawning to help build a transform for the 'spawn actor' node:

'find look at rotation' -> 'make transform' -> 'spawn actor'

Plug the projectile spawn location and mouse location into "start" and "target" pins respectively on 'find look at rotation' node. Plug the projectile spawn location and the result from rotation node into "location" and "rotation" pins respectively on 'make transform' node. Should give you the correct transform.

more ▼

answered Nov 08 '18 at 06:01 AM

avatar image

Goatmeal66
21 2 3

avatar image CODE REDBALLG Nov 08 '18 at 06:26 AM

Can you show me a blueprint of this?

avatar image Goatmeal66 Nov 08 '18 at 06:38 AM

In this project the 'sphere' object is where the projectile spawns.

alt text

spawnactor.png (97.0 kB)
avatar image CODE REDBALLG Nov 08 '18 at 04:01 PM

Hello! Is there any way to make it where the bullet comes out of the socket. Would I have to get the socket location. If so how?

(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