how do i create objects without repeating the last position

Just started using Construct 2? Post your questions here

Post » Sun Feb 01, 2015 9:52 am

Hi I know this will be an easy answer for most of you but its giving me grief. I have 5 positions that I want to create an object at but without repeating the last position.

I have no problem creating the objects but sometimes either with Random or Choose commands they repeat the same position.

I am having trouble working out how to use the boolean instance to control this.

If anyone has a capx. that shows me the answer I will be very grateful. I am fairly new to construct 2 and also am 68 years old and having trouble learning some of the aspects.

Thanks to anyone in advance who can help me. Cheers Robbo128
B
8
S
4
Posts: 9
Reputation: 770

Post » Sun Feb 01, 2015 10:17 am

I knocked together a quick example. Hopefully the code is understandable, but keep in mind its probably pretty rubbish. The technique works though.

Every 2 seconds I generate a random number, which I take the ceil of to round up. I compare that to the LastPlace variable I made, which starts at 0. When they don't match, I go ahead and print the place to a column on the left, then set the last place to that random number. Then I generate another random number and check if they match. If they do, I generate another random number using the same formula, and print a message in the column on the right to show that its working and when a collision has happened.

I also used a boolean in the sample to show you how to work with it. To check whether its false you have to invert it from the right click menu.

Now you just need to translate the places into destinations.
Screenshot (5).png
You do not have the required permissions to view the files attached to this post.
B
6
Posts: 16
Reputation: 284

Post » Sun Feb 01, 2015 11:14 am

Hi Saumanahaii thanks for the help I'm being a complete div and cannot work out how to change the places. I have uploaded a capx and perhaps you could have a quick look at it for me. Cheers Robbo128
You do not have the required permissions to view the files attached to this post.
B
8
S
4
Posts: 9
Reputation: 770

Post » Sun Feb 01, 2015 12:39 pm

And done. Might have been better to create instances of a single boundary rather than have a new object for each, though. Then you could have used a single event to reference the ID and been done.
You do not have the required permissions to view the files attached to this post.
B
6
Posts: 16
Reputation: 284

Post » Sun Feb 01, 2015 2:27 pm

Hi Thanks for the help but it does not appear to work.
B
8
S
4
Posts: 9
Reputation: 770


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest