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"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

Firing event randomly - problem

Hi there,

Fairly new to BP scripting but just when I think I'm getting somewhere, I get stuck! I am trying to do a fairly simple thing - to make a random sound (from a possible 3) fire on a random timed trigger.

tried many things but the example I am posting is after a fair bit of time has passed and I've gotten more and more convoluted, so apologies for the no doubt awful logic!

In summary, I am firing a custom event on Begin Play that runs a function. That function has a timer in it that fires randomly between 1 and 5 seconds (for testing). I can see at runtime that this happens, but in-game the event only fire once (plays one sound, once) and then not again, despite the function appearing to fire internally over and over correctly.

Can somebody tell me what I'm dong wrong and perhaps post a fix of my current logic or show me a simpler way of doing what I want to do please? Don't get too complex without visual aids because I'm not mega experienced as yet and it'll go over my head - probably :)

LEVEL BLUEPRINT FUNCTION

Thanks!

Product Version: UE 4.8
Tags:
timer1.png (232.3 kB)
timer2.png (86.9 kB)
more ▼

asked Aug 18 '15 at 12:06 AM in Blueprint Scripting

avatar image

dazuk1978
42 10 17 21

avatar image ViceVersa Aug 18 '15 at 12:31 AM

i think the problem youre having is that youre using event begin play, so it will function how you want to Once at the beginning of your game, and thats it. I would use event tick(which is similar to the update function in unity) and use a delay node that goes between 1 and five seconds. Im not quite sure exactly how to lay that out but i hope that helps

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Ok for starters BeginPlay only fires ONCE when the map has loaded and gameplay has begun.

So you should put your random sound logic in a FUNCTION then fire that off with a SetTimer.

So connection should be BeginPlay-> SetTimer (Function->yourfunction/ Timer-> your choice or random/ Looping-> checked)

more ▼

answered Aug 18 '15 at 12:39 AM

avatar image

DJMidKnight
1.2k 50 24 50

avatar image dazuk1978 Aug 18 '15 at 09:32 PM

Hmm, I thought that's what I'd done? I have the Function fire once, then inside that it is the timer which keeps firing (and i watch it keep firing every x seconds (randomised). The problem is, that function doesn't seem to actually kick out a pulse re-firing the audio in the next leg of its journey - except for the first time.

Maybe the timer goes before the function. I'll check it/ thx

avatar image dazuk1978 Aug 18 '15 at 09:51 PM

Okay putting the random sound stuff in the function, with a timer before that worked nicely. thanks man

avatar image DJMidKnight Aug 19 '15 at 02:29 AM

Great please mark as solved so other users will know

(comments are locked)
10|2000 characters needed characters left
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