Help with an Or block

Get help using Construct 2

Post » Thu Aug 10, 2017 1:57 am

I have an issue using an OR block. Here is the code:

Image

When you press W, the player sprite gets sent to a dash state moving him forward. This works when the player is on the ground, however when you jump and push W, the player doesn't dash. It should dash because AirDash=1 right? If I delete the "Player is on floor" event, the player can then air dash as expected. Why doesn't it trigger with both conditions in the Or block?

Here us the capx if anyone wants to check it out.

Thanks for any help
B
80
S
52
G
41
Posts: 370
Reputation: 25,830

Post » Thu Aug 10, 2017 2:17 am

C2 has always struggled with OR, as OR just doesn't fit well with C2's primary mechanism of 'picking'. The problem here is both conditions are run, but that means that the 'on floor' condition has now picked no objects, so by the time the code reaches the action, no Players are picked. To prove this, add a sub-event that does a pick-all on Player, and move your action there. You'll see it now works.

I avoid OR generally, as it just doesn't work well when picking gets involved. Either split up the conditions, or work around the issue as explained here.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Thu Aug 10, 2017 2:47 am

blackhornet wrote:C2 has always struggled with OR, as OR just doesn't fit well with C2's primary mechanism of 'picking'. The problem here is both conditions are run, but that means that the 'on floor' condition has now picked no objects, so by the time the code reaches the action, no Players are picked. To prove this, add a sub-event that does a pick-all on Player, and move your action there. You'll see it now works.

I avoid OR generally, as it just doesn't work well when picking gets involved. Either split up the conditions, or work around the issue as explained here.


Well that's confusing. Thanks for the advice and workaround!
B
80
S
52
G
41
Posts: 370
Reputation: 25,830

Post » Thu Aug 10, 2017 10:31 am

The actions run, as explained in the manual here:
https://www.scirra.com/manual/75/how-events-work

There is just no object picked.

This is a the logic (not a workarround) if you would insist using 'OR' in a picking situation.
https://www.dropbox.com/s/0fb3727hnew5r ... .capx?dl=0

Personal i never us 'OR' when picking.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Aug 10, 2017 11:55 am

Or won't be working properly with overlapping condition. It would be better separate condition in different events for overlapping test.
ImageImage
B
108
S
49
G
23
Posts: 783
Reputation: 22,611

Post » Thu Aug 10, 2017 2:41 pm

99Instances2Go wrote:The actions run, as explained in the manual here:
https://www.scirra.com/manual/75/how-events-work

There is just no object picked.

This is a the logic (not a workarround) if you would insist using 'OR' in a picking situation.
https://www.dropbox.com/s/0fb3727hnew5r ... .capx?dl=0

Personal i never us 'OR' when picking.


I did read the manual but it didn't click until blackhornet explained it. Just for clarity, does the OR not work because Platform on Floor = False so it clears the picking list?

I'm staying away from OR as much as possible anyway now. It's a shame because it's much cleaner than separating the events and repeating the actions.
B
80
S
52
G
41
Posts: 370
Reputation: 25,830

Post » Thu Aug 10, 2017 3:35 pm

The OR works, however the SOL is devoid of any "Player", so no "Player" action can occur.

Since you probably have only one player, I guess you could add a subevent with a "Pick all Player", and put your action in there.

Like this :
Image
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Thu Aug 10, 2017 4:23 pm

I believe your problem may be in the values of the variables ...
Huemerson
B
22
S
16
G
21
Posts: 108
Reputation: 16,913

Post » Thu Aug 10, 2017 7:25 pm

@Magistross

That is a new construction 4 me, ty for sharing.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Aug 10, 2017 7:35 pm

@UberLou

It is just how it works. C2 is mostly about picking.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 16 guests