I actually hate the 'pick instance' events..

Get help using Construct 2

Post » Sat Feb 23, 2013 3:59 pm



This is what should happen:

Function call "CreatePC" > Set "UID" to expression (FunctionCall return value) (which is the newly created object UID. I have these functions seperated because I want to use CreateUnit_func on a more global scale) > Pick instance with UID "UID" > Do actions to this Unit.UID

This is what happens:

Function call "CreatePC" > Set "UID" to expression (FunctionCall return value) > Pick instance with UID "UID" > Nothing happens.

I suspect its not properly picking the newly created object. I don't see why not.

CreateUnit_func is working, the object is created, and I also know that the local variable "UID" is getting set its UID. It's just not picking it.
B
11
S
5
G
3
Posts: 19
Reputation: 2,969

Post » Sat Feb 23, 2013 4:13 pm

Newly created instances are not fully created until the end of the next top-level event. In this case it's not really created until the event calling "CreateUnit_func" finishes. It's a limitation in the engine - you need to make sure all initialisation is done in the event that creates the object.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Sat Feb 23, 2013 9:36 pm

I was suspecting that, but I couldn't quite confirm. Thanks!
B
11
S
5
G
3
Posts: 19
Reputation: 2,969

Post » Sun Feb 24, 2013 4:06 am

To Ashley. I know it's part of the limitation of the engine, but it's more frustrating to use. Especially when designing I want to create object linking.

Currently I do
create object
wait 0.02
uid = object.uid

this so far works. but feels sloppy :(
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Sun Feb 24, 2013 10:16 am

[QUOTE=jayderyu] To Ashley. I know it's part of the limitation of the engine, but it's more frustrating to use. Especially when designing I want to create object linking.

Currently I do
create object
wait 0.02
uid = object.uid

this so far works. but feels sloppy :([/QUOTE]

I recall 'wait 0' works as well, it divides it into two sections that are executed one after another. Feels a bit cleaner to me, basically the same thing though :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 28 guests