Anything equivilant to an 'OR' function?
sniffy176
Member, PRO Posts: 48
Hi,
I'm creating a pinball-esque game, but instead of the plunger up the side I just want to spawn the ball from the middle of the table.
I want the ball to randomly start by accelerating in 1 of 2 possible directions.. 135 degrees or 25degrees.
Is there an easy way of doing this? Ideally there would be an OR function, so it could set it to:
accelerate in direction: 135 or 25 relative to scene etc.
I know I could probably set up a random number min1 max2 (x), and a game attribute boolean then an 'if x >=1 , boolean true, else false... etc and then
if boolean true
accelerate in direction 135
else
accelerate in direction 25
etc etc...
but that just seems an extraordinary amount of processing just to choose between 2 numbers?!
Any help in the right direction (pun intended!) would be greatly appreciated!
Sniffy176
I'm creating a pinball-esque game, but instead of the plunger up the side I just want to spawn the ball from the middle of the table.
I want the ball to randomly start by accelerating in 1 of 2 possible directions.. 135 degrees or 25degrees.
Is there an easy way of doing this? Ideally there would be an OR function, so it could set it to:
accelerate in direction: 135 or 25 relative to scene etc.
I know I could probably set up a random number min1 max2 (x), and a game attribute boolean then an 'if x >=1 , boolean true, else false... etc and then
if boolean true
accelerate in direction 135
else
accelerate in direction 25
etc etc...
but that just seems an extraordinary amount of processing just to choose between 2 numbers?!
Any help in the right direction (pun intended!) would be greatly appreciated!
Sniffy176
Comments
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Aren't they a minimum and a maximum amount though?
If I put random(25,135) the ball would be able to set off in any direction between those 2 numbers, whereas I want the ball only to be able to accelerate to 25 or 135 degrees. Not all points between.
25+random(0,1)*110
Thank you so much for that.
There are probably quite a few easy ways to select from a couple of numbers.
-85 + (random(1,2)*110)
135 / (random(0,1)*5.4)
etc etc
Or set up a table, stick your two numbers in separate columns or rows and select random column / row (1,2).
There are probably dozens of other ways.
Just seen Manto1’s post, that's the most elegant / straightforward way by far.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Actually, an "OR" can be made in GameSalad by changing the "All" to "Any" in a rule. Then if condition 1 "OR" condition 2 is true, the result will happen. Using the otherwise section is equivalent to "NAND" if the rule is set to "All" and "NOR" if the rule is set to "Any".
Good tips !
In the context of how he was using 'or' ("accelerate in direction: 135 or 25 relative to scene etc") - I thought some clever use of 'otherwise' might be closer . . . . something like: if the rules for '25' are met then use '25' otherwise use '135'.
?