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"

Set Int to switch a specific number of times

I'm using Switch 2 and Switch 3 to trigger four things in a row, through a timer.

I want to use Switch 1 to trigger either Switch 2 or 3 but I want it to trigger 4 times in a row, each time.

So I need to get either 0 or 1 randomly, but to count up 4 each time - so that the Switch 2 (connected to pin 0) will trigger 4 times if 0 comes up and Switch 3 (connected to pin 1) will trigger 4 times in a row if 1 comes up.

Any ideas?

alt text

Product Version: UE 4.18
Tags:
int.png (94.8 kB)
more ▼

asked Dec 13 '17 at 08:01 PM in Using UE4

avatar image

Donalf
51 8 15 22

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

1 answer: sort voted first

This should work:

alt text

capture.png (138.5 kB)
more ▼

answered Dec 13 '17 at 09:09 PM

avatar image

Everynone
14.8k 77 25 62

avatar image Master Gebjeter Dec 13 '17 at 10:16 PM

Why not just using a branch for switch one?

avatar image Everynone Dec 13 '17 at 10:32 PM

You can. You'd still need to roll the dice somehow, though. There's like 10 ways of doing this, anyway. Was sticking to what OP had already. Not sure what is planned for this further down the line.

Besides, I feel this node is underused so I mention it every time I have a chance ;p

avatar image Donalf Dec 13 '17 at 11:04 PM

If I use the random bool it'll go randomly between Switch 2 and 3 - I need to get it so if it goes to Switch 2 first it'll trigger four times in a row, or if it goes to 3 it'll trigger four times in a row.

The four wires going into the first sequence trigger one after another through a timer - I need to get the first switch to go either 0 four times or 1 four times in a row - or some other way that I can randomly go between Switch 2 and Switch 3, but always firing four times in a row - so that modules of a semi random music system will play in sync.

The four audio components on the left need to synchronise with four audio components on the right, but there are two possible sequences that can occur.

alt text

int.png (246.1 kB)
avatar image Everynone Dec 14 '17 at 08:19 AM

I need to get it so if it goes to Switch 2 first it'll trigger four times in a row, or if it goes to 3 it'll trigger four times in a row.

This is precisely what the code I posted does... Did you test it? When an impulse is sent to switch #1 and pin 0 is selected, the script will iterate through a loop once - the loop is 4 elements long so it will trigger switch #2 4 times in a row. The switch will pull the Index2 from the 4Array0 and fire one of its pins 4 times.

Did you want to fire the switch's #2 and #3 pins consecutively instead?

By the way, your random integer is set incorrectly, it starts at 0. Now you have a 33.3% chance to trigger 0,1 or Default at switch #1

avatar image Donalf Dec 14 '17 at 01:42 PM

Sorry Everynone, I should have been more clear. Because the impulses from the audio components are on a timer, they send in 2 second intervals - so the impulses received by either switch #1 or switch #2 are arriving one after another, not at the same time, meaning the bool randomises with each impulse. I'm trying to get it so that if it goes to switch #1 first it will fire four times in a row, along with the two second timer or if it goes to switch #2 it will fire four times in a row.

I've made a video to clear it up https://www.youtube.com/watch?v=Eci0BjTN8w8

avatar image Everynone Dec 14 '17 at 03:48 PM

In that case, generate the random for #1 earlier, store it in a variable and use it 4 times. And only re-generate the random when necessary.

avatar image Donalf Dec 14 '17 at 05:23 PM

That's what I'm trying but can't figure out the BP needed!

(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