Functions don't identify object.

Discussion and feedback on Construct 2

Post » Wed Jun 05, 2013 12:32 am

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 r132Xionor2013-06-05 00:43:27
Posts: 233
Reputation: 1,537

Post » Wed Jun 05, 2013 2:08 am

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)
Posts: 2,457
Reputation: 15,177

Post » Wed Jun 05, 2013 2:23 am

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 : <
Posts: 233
Reputation: 1,537

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 2 guests