How do I write a function to do something 50% of the time?

Just started using Construct 2? Post your questions here

Post » Tue Nov 04, 2014 3:37 am

Hello;

I have a bullet that when destroyed creates either explosionOne or explosionTwo 50% of the time. I wrote a function event BulletExplodes that just creates explosionOne and it works fine. How do I write an IF(random(10)<5) type branch to do either explosionOne or explosionTwo. I don't see any way to do an if type statement inside a function.

Thanks for your time.
B
34
S
8
G
3
Posts: 169
Reputation: 3,305

Post » Tue Nov 04, 2014 3:40 am

System:Compare two values
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Tue Nov 04, 2014 5:00 am

Is this the kind of thing you mean? I can't use Else here for the other explosion.

Thanks for your help.
You do not have the required permissions to view the files attached to this post.
B
34
S
8
G
3
Posts: 169
Reputation: 3,305

Post » Tue Nov 04, 2014 5:49 am

You've got Else at the wrong level. Click on event 16 between the minus sign and the cog - that selects the whole event, then press X. That will give you an Else for that event.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Tue Nov 04, 2014 11:11 pm

I appreciate the help--so I moved up the else but it still won't accept it.

Thanks for your time again.
You do not have the required permissions to view the files attached to this post.
B
34
S
8
G
3
Posts: 169
Reputation: 3,305

Post » Tue Nov 04, 2014 11:19 pm

Don't move the Else up, follow my instructions. (Delete the bad Else first).
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Tue Nov 04, 2014 11:37 pm

Great!!! I got it to work.

Thanks blackhornet. I forgot the X.
B
34
S
8
G
3
Posts: 169
Reputation: 3,305


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests