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"

Problems in continuous fire

When I hold down the fire key, I can continue to shoot even if the number of bullets is zero. alt text

How should I revise it?

Product Version: UE 4.20
Tags:
more ▼

asked Oct 18 '18 at 11:55 AM in Using UE4

avatar image

A1exYaSw
13 1 1 3

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

2 answers: sort voted first

in your example the value of the loop pin will not change unless you press the button again. this means that the check for amount of ammo is not being done which is due to using a timer here. theres two ways to solve this:

first you could add a check after the start fire event which checks the ammo level and if theres no ammo then you clear the timer, in this case you would just have the timer set to always loop. see picture capture1.

the second method would be to rebuilt the script entirely and eliminate the timer, instead opting to make your own loop. see picture capture.

alt text

alt text

capture1.png (267.4 kB)
capture.png (155.6 kB)
more ▼

answered Oct 18 '18 at 01:32 PM

avatar image

ThompsonN13
10.1k 33 10 23

avatar image A1exYaSw Oct 19 '18 at 02:20 AM

Thank you. I learned a lot of new knowledge.

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

That's because your logic is wrong. You are only checking ammo before you set the timer. Once the timer is set it keeps calling ShootFire without checking ammo.

simply check ammo on start fire before calling shoot fire..

more ▼

answered Oct 18 '18 at 01:44 PM

avatar image

Steve SybrSyn
1.5k 4 5 10

avatar image Steve SybrSyn Oct 18 '18 at 01:49 PM

Wops, looks like Thompson beat me to it with a more details and better solution

avatar image A1exYaSw Oct 19 '18 at 02:17 AM

Thank you. Your answer is very useful for me.

avatar image Steve SybrSyn Oct 19 '18 at 04:26 AM

You are welcome, I'm glad I could help!

(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