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"

Want my projectile to fire continuously when my key is "held down"

So I have a firing projectile, it fires single individual rounds only when I press my LMB once, I want it to fire continous shots when my LMB (or keyboard key) is held down, how do I do that?

Product Version: UE 4.17
Tags:
more ▼

asked Mar 01 '18 at 08:30 AM in Blueprint Scripting

avatar image

True Origins Int
57 7 16 27

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

4 answers: sort voted first

Indeed there are multiple ways to achieve this, see THIS thread.
It's rather old, but I think you'll find some ideas there that might match your existing setup & goal.

Also - note @Shadowriver's comment about using Event Tick for this -
You'd probably be better off using a combination of a Gate and a certain Delay after each shot.
(And as a side-note - if you turn that Delay's Duration into a variable, you'll get a weapon/character with a dynamic rate of fire)

more ▼

answered Mar 01 '18 at 11:46 AM

avatar image

WaxOff
51 3 7

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

below is a basic script to get this working. basically you have a variable and set it to true when the button is pressed and false when released. then call the fire function. this function will keep firing until the variable becomes false.

alt text

capture.png (145.1 kB)
more ▼

answered Mar 01 '18 at 04:28 PM

avatar image

ThompsonN13
10.1k 33 10 24

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

You have several option to do that..

1: Axis Bind : https://www.unrealengine.com/en-US/blog/input-action-and-axis-mappings-in-ue4

Axis bind continously gets called in every frame with input value.. that means input value is 0 by when input is not pressed and goes to specified range (you can specify that in project settings / input). For example if your axis bind configured as 0 - 1 and if you press mouse button input value would be 1..

So because of continously call you can check for that 1 and at that point you know mouse button is pressing..

However firing projectile i think you should have some delay between shoots.. so

2: You can do a bool variable in your weapon or character class... when mouse button pressed you set that true. Other mechanism should be done in TICK event, so you can check is button bool true or false and do your logic like add deltatimes or delayed triggered events etc..

this topics contains some tips about this: https://answers.unrealengine.com/questions/31437/mouse-left-button-down-to-shoot-automatically.html

Cheers

more ▼

answered Mar 01 '18 at 09:03 AM

avatar image

AmphDev
1.5k 15 9 33

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

Hello! I think in this video, Zak Parrish shows something very similar to what you want to achieve

https://www.youtube.com/watch?v=FYMQLuUXjp8∈dex=10&list=PLZlv_N0_O1gb5sdygbSiEU7hb0eomNLdq

more ▼

answered Mar 02 '18 at 03:01 AM

avatar image

stehc88
1 1 2

(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