Unpin without behavior

Get help using Construct 2

Post » Fri Jun 14, 2013 2:59 pm

Hi,

I'm trying to figure out a way to have an object "grab" another object in mid-air, carry it for x amount of seconds and release it at an upward angle, continuing the original trajectory.

Here's the premise: The player is shot out of a cannon (using bullet behavior). If he collides with a flying object , the bullet behavior becomes inactive for 3 seconds while the object carries the player on a straight trajectory. After the 3 seconds are up, the player gets released at an upwards angle.

The flying object is moving with a bullet behavior as well.

I'd like to set an action where the player has an image point on his back, and the flying object has another image point at its "feet", so when the overlap happens, the player seems to be carried by his back.

I've tried using the pin/unpin behavior on the player, but the issue is that it pins at either angle/rotation or both (rope or bar don't work for this). I know that move to position at every tick can be used to replace the Pin behavior. I'm not sure how to Unpin it though.

Makes sense?

Thanks.
B
19
S
5
G
6
Posts: 32
Reputation: 4,194

Post » Fri Jun 14, 2013 5:34 pm

Well, the pin behaviour is the best bet for this purpose, but you first need to set its position, then pin it (both in the event sheet), for best results (in this case, at least). Unpinning can be done in the event sheet as well.

Your other option, which is functionally the same as using the pin behaviour, is to set position to another object each tick, specifying the desired image point. This way you can specify another condition, maybe a timer, and when that other condition is no longer met, the child object will simply cease to be "carried".

Here's a quick example (r134). Drag the green block onto the pink one.
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Fri Jun 14, 2013 11:17 pm

Thank you very much @GeometriX!
Your example worked. The main issue I'm getting now is that regardless of the "carrier" objects in the screen (they're all copies of the first one), the player always sets position to the first one - as shown in the image below.

I'm assuming it has to do with UID's, but I'm not sure how to specify the Set Position to the the colliding carrier.

The interesting thing is that the colliding carrier gets the bullet effects set in the events.



Thanks.
B
19
S
5
G
6
Posts: 32
Reputation: 4,194

Post » Sat Jun 15, 2013 12:33 am

You need to store the UID of the carrier so you can Pick it again later to do your positioning.
ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227

Post » Sat Jun 15, 2013 2:19 am

How do you do that?
Sorry if it's a basic question. I know it's possible to do that with an array or a loop, but not with pre-existing copies (at least not that I found).
B
19
S
5
G
6
Posts: 32
Reputation: 4,194

Post » Sat Jun 15, 2013 3:48 am

Add a variable instance to the player, and when the player gets grabbed, go "set player.variable = carrierobject.uid"

That way, you just add "if carrierobject.uid = player.variable" to the conditions and it will pick the carrierobject your player got grabbed by.
B
21
S
8
G
6
Posts: 346
Reputation: 4,891

Post » Sat Jun 15, 2013 5:41 am

ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227

Post » Sat Jun 15, 2013 4:53 pm

Brilliant!
Thank you very much @blackhornet for the example.
And thank you all for clarifying the process.

Clarity is in sight (yes, pun intended)
B
19
S
5
G
6
Posts: 32
Reputation: 4,194


Return to How do I....?

Who is online

Users browsing this forum: wizdigitech, Yahoo [Bot] and 10 guests