How do I use a function corretly

Get help using Construct 2

Post » Sat Jan 09, 2016 12:50 am

Hi Folks, i have a simple function which should update the position of a object.
However, if i call the funtion after the object is created it does not update the position. When i and an 1 Tick delay it does.
Can somebody explain this to me please?

Does not work:
Image

Does Work:
Image

Kind regards
Patrick
B
19
S
7
G
1
Posts: 222
Reputation: 2,551

Post » Sat Jan 09, 2016 1:17 am

Newly created objects are inaccessible outside of the event they were created in until the next tick. Two more things to note just in case you're not aware (just some useful info):

1. A wait time of 0 seconds will wait until the next frame.

2. Functions don't remember objects picked by the event from which they were called. If you want the function to work with a specific object, you'll have to pass in your object's UID as a parameter and pick it inside the function.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,126

Post » Sat Jan 09, 2016 1:27 am

WOW, that was a fast answer, thank you very much!
Havent found anything about this in the manual, but i could imagine its something like that :D hopefully i am not just blind haha

1) -> Perfect :D

2) Thats a very usefull information, even if this is not the case here it will help in the future!

Kind regards
B
19
S
7
G
1
Posts: 222
Reputation: 2,551


Return to How do I....?

Who is online

Users browsing this forum: JayH, tarek2 and 12 guests