Random X direction

Get help using Construct 2

Post » Mon Jun 03, 2013 11:02 am

Hi,

I'm doing a pong tutorial where the ball always goes by force physics to one direction. I would like to randomize the X direction to start negative sometimes (facing the other player).

For that matter I made a numeric variable 0,1 where if 0 the ball goes to positive velocity, 1 it goes negative.

The ball wont move if it's set to random. What am I doing wrong?

Here's this script:



Project Demolonrot2013-06-03 11:05:06
B
4
S
1
G
1
Posts: 53
Reputation: 858

Post » Mon Jun 03, 2013 1:35 pm

start with an absolute value. abs(value here). It will always start possitive becasue absolute values ignore Plus and Minus.
B
9
S
3
G
3
Posts: 70
Reputation: 1,990

Post » Mon Jun 03, 2013 2:50 pm

Random(0,1) returns a random floating point value between 0 and 1. You might want to try choose(0, 1).
B
62
S
26
G
24
Posts: 954
Reputation: 18,318

Post » Mon Jun 03, 2013 6:12 pm

[QUOTE=Magistross] Random(0,1) returns a random floating point value between 0 and 1. You might want to try choose(0, 1).[/QUOTE]

Thank you very much guys. Choose does the job.
B
4
S
1
G
1
Posts: 53
Reputation: 858


Return to How do I....?

Who is online

Users browsing this forum: Darknessed, shubhamrathi9, surendhra, tetuan and 11 guests