How do I pass an instance through a function?

0 favourites
  • 3 posts
From the Asset Store
Assets for creating mountains and ravines environments
  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)