Functions don't identify object.

0 favourites
  • 3 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hi, I have a problem with functions.

    My events are as follows.

    onFunction "Reward" : create Object3 at (Object2.X, Object2.Y)

    Object1 onColission with Object 2:

         --> callFunction "Reward"

    The Function fails to identify which Object2 the colission took place with if there's 2 or more on screen.

    Manually writing the function code instead of calling the function works perfectly.

    Is this a bug or am i doing functions wrong?

    Using r132

  • Your using the function wrong.

    On Function "reward"

    Pick Object by UID(Function.param(0))

    -- creatobject(object.x, object.y)

    On Collision(whatever)

    -- Function.Call(reward, object2.uid)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm afraid I don't understand.

    I am using functions as described in the manual here :

    Simply to avoid not repeating the same lines over and over.

    That "create Object3 at (Object2.X, Object2.Y)" line is followed by 10 others which repeat on 5 different collision events in the project, and that's why I wanted to make it shorter for when editing the events.

    I can't seem to grasp the method you're suggesting.

    I don't think you can call a pick object by UID as an Action. Nor can I visualize how the function would locate the collided object without doing another collision check on its own, which basically makes the whole point of the function moot to begin with.

    The correct object is already picked/selected by the first Colission event, which called for the function.

    Maybe it's a bit too late in the evening for me but I really am having a hard time grasping your idea : <

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