How to randomly select -50 OR 50 (but NOT between)

Get help using Construct 2

Post » Thu Mar 19, 2015 11:30 pm

When a particular action happens in my game, I want the computer to randomly select either -50 or 50. However, I do not want the computer to select any figures between -50 and 50.

I know that to allow the computer to randomly select any number between -50 or 50 I would use the following command: random(-50,50)

However, in this particular instance, I only want the computer to randomly pick either -50 or 50. How exactly do I do that?

Thank you in advance
B
9
S
2
Posts: 111
Reputation: 1,010

Post » Thu Mar 19, 2015 11:35 pm

choose(-50,50)
ImageImageImage
B
71
S
20
G
189
Posts: 3,533
Reputation: 107,840

Post » Fri Mar 20, 2015 12:17 am

wow! Thank you for your very prompt response. That certainly answers my question. However, something still confuses me:

I used that exact command that you suggested: choose(-55, 55)

Oddly however, when the bottle is hit with the ball, the bottle does not always fall to the left or to the right. Sometimes, the bottle Barely moves at all to the left or to the right. It is almost like the computer thinks it is using the random command and not necessarily selecting -55 OR 55.

Any idea what could be causing this issue? Again, I absolutely used the command you suggested: choose(-55, 55) for the "apply physics Force" for the "force X". I intentionally left the force for Y at zero.

Any ideas?

PS: I changed the choose(-55, 55) instead just to a single number and once I changed it to a single number, the bottle fell over every single instance without exception. However, once I returned back to using that choose command, it seems that the computer would get confused and randomly barely move the bottle at all. Therefore, perhaps, that choose command might not be working properly?
B
9
S
2
Posts: 111
Reputation: 1,010

Post » Fri Mar 20, 2015 5:09 am

The forum is refusing to let me attach for some reason. I tried a quick experiment, and it was working fine. Maybe post an example of what is failing.
ImageImageImage
B
71
S
20
G
189
Posts: 3,533
Reputation: 107,840


Return to How do I....?

Who is online

Users browsing this forum: buzzfrog, JoshSenpai, mehrshadfarahani, Pulstar, Silviu, waltg, Yahoo [Bot] and 8 guests