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
B
10
S
3
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)
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,013

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 : https://www.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 : <
B
10
S
3
Posts: 233
Reputation: 1,537


Return to Construct 2 General

Who is online

Users browsing this forum: nemezes, twomonocles and 8 guests