Pick Instance by comparisson On Created?

Get help using Construct 2

Post » Tue Aug 02, 2016 9:28 am

Heya fellas!

My quest on getting the handle of this fine software continues. I have a seemingly trivial matter I can't seem to resolve.

I create these Node Objects and I want upon creating every Node Object to set the position of a specific Unit object to the Node object that was just created. For the task at hand the Unit has a Name var and the Node has a Owner var which he gets through other means but that's not important right now. The var is set to the proper value - that much i'm certain.

Now, what comes to my mind is that with a On Created condition, all actions and sub conditions should take the context of the object that was just created in amy comparisson whatsoever. But this does not seem to be the case. Please take a look and point out what im doing wrong. Much appreciated.

CHeers!



Image
B
18
S
3
Posts: 65
Reputation: 994

Post » Tue Aug 02, 2016 11:38 am

Question.
Is Unit created in the same tick as Node ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Aug 02, 2016 11:41 am

No, it exists in the layout.
B
18
S
3
Posts: 65
Reputation: 994

Post » Tue Aug 02, 2016 12:27 pm

You can not Pick (select) Node yet at that point.

Newly created instances are selectable in the next top-level event. On creation acts as it is in the same event and on the same place as the creation/spawn action. So, it does not count as a top-level event.

The same is true for functions.

But. There is 1 pick event that always works, no matter where or when you use it. And that is sprite > Pick by unique ID.

So this is how you can do this:
https://www.dropbox.com/s/9tqv7j27zmodn ... .capx?dl=0

What is the top-level event ? It just the next 'non sub event'.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Aug 02, 2016 12:44 pm

Just to clarify what 'the next top-level event' is.

https://www.dropbox.com/s/gy5hk7hw80m3h ... .capx?dl=0

Event 5 is, compared the event 3, the next top-level event.
As you see, Node is perfect pickable at that point.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Aug 02, 2016 12:48 pm

Thanks man, yet again. :), This should do the trick.

To answer your question, another object goes around and spawns Nodes upon colliding with certain objects and fills the Owner var. The ideas is that the Unit object happily waits for a node object to be spawned with the node's owner var corresponding to the Unit's name var, and then should start doing stuff with the nodes within that context...and because there are several unit objects which follow different nodes, it was important to pick the correct unit based on the owner var. So yeah, this should def get the job done. Thanks again.

Cheers!
B
18
S
3
Posts: 65
Reputation: 994


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 15 guests