branching without selection

For questions about using Classic.

Post » Fri Oct 01, 2010 5:49 am

Greetings.

Now I found the following seemingly simple branch case:


Event 23 should set an angle randomly to 0 or 90,
then Event 24 should execute only when angle == 0.

But Event 24 always executes!!

Where is the trouble, random worked in an other case already.
The IF selection is wrong?

Thanx for watching.
B
2
G
2
Posts: 51
Reputation: 752

Post » Fri Oct 01, 2010 6:22 am

Fifty fifty chance... so it just might seem to always end up 90.
Actually I would assume this is an issue with ticks, since the angle of the object is already 90 at the beginning of the event.
Try a function
>-call function ("onetick")after delay 23ms

>-on function "onetick"
>--enemybox angle =0... do this
Image Image
B
161
S
48
G
90
Posts: 7,350
Reputation: 66,755

Post » Fri Oct 01, 2010 1:24 pm

that "angle" is already in the condition is not the reason for failure, I used it already sooner.

Maybe there is a workaround with functions for this, but I would rather understand the true reason, to see inside more deeply.
B
2
G
2
Posts: 51
Reputation: 752

Post » Fri Oct 01, 2010 2:04 pm

Without seeing everything it's hard to tell if it'd make a difference, but have you tried placing a "Trigger once while true" condition on event 23?

The way it is now makes event 23 calculate on every tick, so if you're running the fps at standard rate you'll have around 50-60 ticks, give or take, each second. Since the chance of getting either 0 or 90 is 50% you'll have around 30 instances of the event generating the number 0 and the other 30 generating 90 (assuming of course that your framerate is always at a constant 60, which isn't really the point. But whatever =P )
B
73
S
20
G
10
Posts: 524
Reputation: 9,896

Post » Fri Oct 01, 2010 2:45 pm

Thanx Mr. inkBot,

that was the solution. thanx for thorough explanation, too.
B
2
G
2
Posts: 51
Reputation: 752


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests