0 Favourites

Functions don't identify object.

  • 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)

  • Construct 3

    Buy Construct 3

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

    Buy 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 : scirra.com/manual/149/function

    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)
Similar Topics Posts Views Last Post
Unread hot topic
167 14,484
DMT2005's avatar
Unread hot topic
123 14,867
Zebbi's avatar
Unread hot topic Locked topic
78 38,318
Ashley's avatar
Ashley Construct Team Founder