How do I pass an object/sprite through a function parameter?

  • Hi guys

    I'm trying to find an easy way to pass an object through a function param, but I can only seem to be able to do it with UID.

    With UID, I need to put an extra sub-event in my function, which breaks the flow of the other inline events (using wait etc.).

    Any ideas would be awesome :)

    Thank you!

  • You could have an instance variable / boolean that you select by in the funciton. Before calling the function set the instance variable for the object(s), then pick by that instead.

    When you call the function you pick objects with the boolean set to enabled, for example, instead of UID.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • tunepunk Cool, thanks heaps :) Yeah, I've been using the instance variable method, then picking it by it's name - it's not too bad of a workaround. Would be cool, if you could just pass the specific object in a param without it tho.

  • There's also a thing Called IID. Can be quite useful at times. It's kind of like UID.

    I don't know why the object properties is not showing this number, but if you check the debugger you can see that every object has an IID (instance ID) as well.

    You can then use the System expression - Pick nth object. Then you can pick the specific object of that object type by IID instead.

    So send the the object IID with the funciton then "pick nth object".

    Maybe that could work as well?

  • tunepunk Hmmm, interesting ... I'll have to play with this some more, and do some experiments lol. I have it working now, and it's pretty clean, so I'm happy. I'll definitely have a better look at all of this though.

    Thanks heaps for the help, really appreciate it :)

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