Swap data between two objects of the same type?

Get help using Construct 2

Post » Sat Dec 01, 2012 2:56 pm

I have managed to do this - but it's very laborious.

If 2 objects of the same type collide, I want them to swap their angles - simple enough. (Obviously I have to use a holding variable when I swap them.)

The problem is getting the data out of the appropriate picked object - you can't do it without picking them specifically. I ended up with something like this:



Maybe that doesn't look so bad, but if I want to scale it to be a little more complex than that then it quickly becomes and unreadable mess with everything copied into unreadable variables.

Ideally I would be able to do:

tempAngle = ant[0].angle
ant[0].angle = ant[1].angle
ant[1].angle = tempAngle

Is there any way with the picking to get more elegant code like this?
B
11
S
4
G
3
Posts: 70
Reputation: 3,071

Post » Sat Dec 01, 2012 3:04 pm

If you make a family containing only the ant, you can try the collision between the family and the ant, then you can pick them separately
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Sat Dec 01, 2012 3:31 pm

Nice. Thanks.
B
11
S
4
G
3
Posts: 70
Reputation: 3,071


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests