How do I pass an instance through a function?

Get help using Construct 2

Post » Tue Apr 28, 2015 11:13 pm

Hi! I am having a problem with multiple instances acting weird and interrupting each other's intended actions. The enemy event sheet contains a number of functions and as far as I understand it functions disregard instance.UID unless it is passed onto the function? So my question is: how do I pass instance UID onto a function to prevent the contents of the function to affect every instance of an object?

Specifically, when an enemy turns around (turning around is written in a function) every other enemy that don't need to turn around at that moment do so anyway and I guess it's because the function affects every instance because it disregard UID?

I have searched but the only answers I've found has been very hard to understand or explained poorly.

Thanks in advance!

// Elias
B
20
S
8
G
4
Posts: 195
Reputation: 3,555

Post » Tue Apr 28, 2015 11:21 pm

Use the Plugin "Function" Parameter Feature. You can pass any value you want to any function.
Click on "Add Parameter" at Call Function Window. And inside a Function you can use the expression "Function.Param(n)" (n = number / index of added parameter)
You can also buffer your uid number in a variable.
B
13
S
4
G
1
Posts: 107
Reputation: 1,337

Post » Tue Apr 28, 2015 11:42 pm

Thanks for the quick answer DAG!

What I did was:

1) in the function call I added as a param(0) : "instance.UID"
2) in the function I picked instance UID by Param(0) ..

..and it works! Thanks DAG :)
B
20
S
8
G
4
Posts: 195
Reputation: 3,555


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests