Pick by Instance Variable in Family - Create?

Get help using Construct 2

Post » Sat Aug 17, 2013 12:43 pm

I'm trying to make an event to create random objects from a family, but limited to the objects with a specific instance variable value.

I have X amount of objects in a family called Objects. The family has an instance variable called CanBuild.

If an object's CanBuild variable is 1 you can create it, if not you can't.

I've set the CanBuild variable to 1 in one of the objects and 0 in the rest.

I've made following event:

On touched (create button) ---> Subevent ---> Pick Objects where Objects.CanBuild = 1 --->Subevent---> Create object.

But it doesn't create the object. If I remove the Pick Objects condition it just creates a random object from the Objects family.

Any ideas how to do this? I hope it's clear enough.

B
3
Posts: 16
Reputation: 232

Post » Sun Aug 18, 2013 4:47 am

You are telling the program to pick an instance with a certain variable value, but that instance doesnt exists, thats why is not creating anything. You should put the value in another object like the button being touched so:

On touched >
   Subevent> button variable=1 > create this object
   Subevent> button variable=0 > create that object
B
10
S
4
Posts: 133
Reputation: 1,543

Post » Sun Aug 18, 2013 12:04 pm

Thanks for the reply!

I understand what you're saying, but the problem is that I don't wanna create a specific object, but rather create a random object from a range of objects within a family. Is it not possible to choose which objects within a family can be created and which cannot?
I want to make certain objects available only in certains levels etc.

I guess one solution could be to make different families for all the levels..
B
3
Posts: 16
Reputation: 232


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Elliott, Yahoo [Bot] and 69 guests