probability of an event (per object instance)

Get help using Construct 2

Post » Sun Nov 30, 2014 5:43 pm

If I want to make an event happen on 50% chance, I add

System: Random(1) <= 0.5

But, if I want to make an event happen on an Probability% chance and Probability is an instance variable of Player, using these events........

System: Random (1) <= Player.Probability
For Each Player

....... It doesn't work

I have events setting the value of Probability instance variable depending on different situations. and yes, I checked that the values are correctly being set and none of the values are zero, I even tried setting Probability to 1 so 1 means it should always happen, but it is not working.

Help please
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Sun Nov 30, 2014 5:46 pm

Move the For Each up. You need to check the probability for each Player.
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Sun Nov 30, 2014 5:52 pm

@blackhornet
It still doesn't work.

I used "Compare two values" for the System: Random (1) <= Player.Probability condition and I think "Compare two values" can't detect between object instances. Now I need an alternative way of comparing same variable but can detect between instances of Player object.

Any ideas?
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Sun Nov 30, 2014 5:55 pm

Post what you've got so far.
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Sun Nov 30, 2014 6:15 pm

Now, I had to make a new test file showing what I am saying because my game is already complex and it won't help anyone trying to solve this problem because my game has many systems already implemented.

The example file uses keyboard inputs as conditions BUT they are just for example purposes.

In my game, I don't use keyboard inputs as conditions, but you get the point of the problem.
You do not have the required permissions to view the files attached to this post.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Sun Nov 30, 2014 6:28 pm

random(1) will never be 1 ..hardly 0.2
You do not have the required permissions to view the files attached to this post.
B
66
S
24
G
7
Posts: 1,514
Reputation: 11,039

Post » Sun Nov 30, 2014 6:48 pm

Don't use =, use <=.
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Sun Nov 30, 2014 6:56 pm

@korbaach
@blackhornet
ok. thanks

but it still can't distinguish between object instances.

I saw the description of Compare two values in the add action window. It said there it's not for objects.

How do I achieve this for each instance of an object? Is it possible?
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Sun Nov 30, 2014 7:05 pm

.
You do not have the required permissions to view the files attached to this post.
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], brunopalermo, Colludium, kellehk, newt, ST314 and 26 guests