[SOLVED] generate 2 objects randomly but not overlap them

Get help using Construct 2

Post » Wed Jul 27, 2016 8:26 am

Hi
I am again here with one new question
I have a track which has left & right

(x = 100)= this is (L)
(x = 200)=this is (R)

(L) Left is 100 px
(R) Right is 200 px

Now I have 2 objects
Circle & Square
I am creating both randomly on track L & R
>>>>>
on every random (1,3) second > create "Square" on Choose(L,R)
on every random (1,1) second > create "Circle" on Choose(L,R)
>>>>>>
these are overlapping sometime

>>>
I want that
do not create both at a same time (their should a way for player to go ahead)
do not create both at same position

>>>>>>
How can i achieve this result
Last edited by luckyrawatlucky on Fri Sep 16, 2016 6:48 am, edited 1 time in total.
Image
B
64
S
39
G
45
Posts: 647
Reputation: 32,204

Post » Wed Jul 27, 2016 9:20 am

Make the creation happen in a function.

For example
On function "CreateSquare" => Do your creation code.

Add an event Square - On created
And add a condition : Square is overlapping Circle
=> Destroy Square
=> Function "CreateSquare" (so that it creates another instance)

Do the same for your Circle and this should make sure that instances are not overlapping.

To create them at different time, I'm afraid you may need to change your "every random" event to something more determined, and have the timings calling the creation of instances depend on the other.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
288
S
111
G
94
Posts: 7,332
Reputation: 69,160


Return to How do I....?

Who is online

Users browsing this forum: Fradno and 15 guests