How do I select a random action?

Just started using Construct 2? Post your questions here

Post » Tue Jun 30, 2015 9:13 am

if EnemyDestroyed
then
if(random < 0.6)
action1
else
action2

if EnemyDestroyed && (random < 0.01)
then
action1

On a trigger, I want to choose one of many different actions
or
I want to play an action only sometimes

Is there a shortcut way to accomplish this, both fast to implement and execute?
If there is not, what are some pretty fast ways?
B
7
Posts: 10
Reputation: 297

Post » Tue Jun 30, 2015 11:42 am

Pretty much as you say

Enemy.OnDestroy:
System.compare2Values random(0,1) < 0.6 : (Action 1)
Else : (Action 2)

C2 is mostly event driven ; so it isn't really "if enemy destroyed" - it's actions that are executed when the enemy is destroyed.
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Wed Jul 01, 2015 10:02 am

compare2Values

nice one, thanks!
B
7
Posts: 10
Reputation: 297


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests