How does C2 select objects with same variable value?

Discussion and feedback on Construct 2

Post » Tue Sep 12, 2017 1:17 pm

I have 4 objects with an Instance Variable of the same value.

Compare Instance Variable. ObjectID = "Enemy"
Create Text Object.
Set Text Object.UID

To test it I have it creating text and setting it to UID.
It always creates only one text object and it always has the lowest UID for that Instance Variable Value.

It seems like it checks by UID and selects the first object that has the value, because it always selects the object with the lowest UID.
I am not sure if it always works like this or is just coincidence.

I currently have a 2nd variable that allows me to always select a specific object with a specific ObjectID Value.
I would like to remove this variable if possible.
I feel it isn't needed, but I don't want to run into errors later on.
Last edited by Unconnected on Wed Sep 13, 2017 1:21 am, edited 1 time in total.
B
65
S
37
G
13
Posts: 240
Reputation: 12,703

Post » Tue Sep 12, 2017 5:46 pm

If you want to enable it manually I think you just need to add the cordova-plugin-crosswalk-webview plugin and reduce the minimum target SDK.
Scirra Founder
B
398
S
236
G
88
Posts: 24,428
Reputation: 194,625

Post » Tue Sep 12, 2017 8:12 pm

Think Ashley has replied to the wrong post....? Either that or I am in the twilight zone

@Unconnected not sure what your question is.. "How does C2 select object with same instance variable value?"

answer It just does

your code

"Compare Instance Variable. ObjectID = "Enemy"
Create Text Object.
Set Text Object.UID"

will only ever show you the uid of one instance

if you wanted text boxes created for each object with Variable. ObjectID = "Enemy" then use < for each > instead .... no? or am i misunderstanding?

if you wanted to only select one specific one like the first or last pick based on UID im not sure I would depend on what ever ends up in a text box from the unknown inner workings of construct
...
B
45
S
23
G
7
Posts: 291
Reputation: 8,020

Post » Wed Sep 13, 2017 1:05 am

I only created text to see what UID was selected and how.
I was sure of it just selecting 1 because of the way the event was set up.
I wasn't sure if it was looking at more than one before selecting one though.
I never tried to select 1 object with 4 of the same variable values.
It has 4 to select from, I was curious on how it selected 1 of the 4.
It seems it looks at UIDs from low to high and picks the first one that matches the condition.
I was only wanting confirmation or told how if I were wrong.
B
65
S
37
G
13
Posts: 240
Reputation: 12,703


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 12 guests