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
12
S
5
G
3
Posts: 19
Reputation: 3,019

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
398
S
236
G
88
Posts: 24,428
Reputation: 194,600

Post » Sat Feb 23, 2013 9:36 pm

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

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
90
S
18
G
9
Posts: 2,455
Reputation: 15,028

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
9
G
7
Posts: 756
Reputation: 7,302


Return to How do I....?

Who is online

Users browsing this forum: totoe and 37 guests