Pin to Image Point?

Get help using Construct 2

Post » Tue Nov 20, 2012 3:22 pm

I'm trying to have my character be able to lift and carry objects around (and eventually set them down). I had it working where when the player overlapped the object and pressed a button, the object would be pinned to the player. I'd like to use an image point to control the location of the object in the animation. For example, place the player's image point on his hand and have the object stick to it.

I see a set position/angle feature that allows you to choose the Image Point, but can't find anything similar in the Pin Behavior. Any help is appreciated.
B
40
S
11
G
6
Posts: 228
Reputation: 6,951

Post » Tue Nov 20, 2012 6:45 pm

Make sure the object has the PIN behavior attached to it first.
Then you should have an event like:

Player presses (Pickup button) = > pin object to image at image point 0
B
32
S
4
Posts: 406
Reputation: 3,221

Post » Tue Nov 20, 2012 8:24 pm

I don't think there's an option for that under Pin. Once you pin to object, it really only lets you select the mode (position, angle, rope, etc). If there's no easy way, I may create a blank sprite at the image point and then pin the objects to that.

B
40
S
11
G
6
Posts: 228
Reputation: 6,951

Post » Tue Nov 20, 2012 9:10 pm

You just need to set the object's position to the image point before you pin it.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Tue Nov 20, 2012 9:27 pm

[QUOTE=ramones] You just need to set the object's position to the image point before you pin it.[/QUOTE]

That's working for lining up the object first, but I need it to follow the image point in other animations. Its basically lining itself up with the image point in the default pose and then pinning it there. When I switch animations, it still stays in the position from the image point on the default frame.
B
40
S
11
G
6
Posts: 228
Reputation: 6,951

Post » Tue Nov 20, 2012 9:56 pm

What the Pin behaviour does is pretty much just

+ Every Tick
- Set [object] position to (X,Y)

Except that the X, Y coordinates doesn't update after the object is pinned.

If you need more precision, I suggest dropping the Pin behaviour and do it manually, using a boolean or a string value as a state machine to check when the object is grabbed or not.

+ [object] Grabbed = true
+ Every Tick (adding every tick here is not really necessary, but old habits die hard :P)
- Set [object] position to (imagepoint.X, imagepoint.Y)

You're doing almost the exact same thing as the Pin behaviour, but the object will follow the image point, since we are using the image point's coordinates directly.inkBot2012-11-20 22:00:09
B
73
S
20
G
10
Posts: 524
Reputation: 9,896

Post » Wed Nov 21, 2012 4:12 am

I'm afraid I'm really lost. I have conditions set up for the player being over the object (orange box), a variable to check if the player is already holding an object, and what I think is a boolean checking if the box is being held. Then the player should just press the S key to pick it up.

Problem is there is no option to check anything every tick to adjust the position. I can just assign the position, but without the "every tick" function, it just pops to where the image point was on the first frame and stays there.

I've attached my capx file and would appreciate and help on figuring this out. I'm kind of lost. Thanks.

http://dl.dropbox.com/u/56104169/PinTest.capx
B
40
S
11
G
6
Posts: 228
Reputation: 6,951

Post » Wed Nov 21, 2012 9:53 am

@sman118 I'm not sure if this is what you wanted.. but could give it a try anyway:

http://dl.dropbox.com/u/33370253/PinTest_.capx
B
157
S
114
G
8359
Posts: 42
Reputation: 4,188,239

Post » Wed Nov 21, 2012 1:59 pm

@aruche that is AWESOME and exactly what I needed. Problem is that I'm trying to set the object down and any code I try to figure out isn't working. I'm trying to toggle the carrying off and have it end up at the player's image point and left there on the stage.

I really appreciate the help. Also, if you could friefly explain what you did, that would help me learn it for next time. Thanks!
B
40
S
11
G
6
Posts: 228
Reputation: 6,951

Post » Wed Nov 21, 2012 4:53 pm

[QUOTE=sman118] @aruche that is AWESOME and exactly what I needed. Problem is that I'm trying to set the object down and any code I try to figure out isn't working. I'm trying to toggle the carrying off and have it end up at the player's image point and left there on the stage.[/QUOTE]
If you're doing what I think you're doing, you have similar setups for the events for turning carrying on and off. Problem with this is that they will toggle in order.

This order of events:

+ Player presses S
+ Carrying = false
- Toggle Carrying

+ Player presses S
+ Carrying = true
- Toggle Carrying

It's first going to toggle the Carrying variable, but instantly afterwards it's going to toggle it again, because the conditions for that event have now become true. This will give the appearance that it doesn't work and you can't pick up the item, while in reality you're picking it up and immediately putting it down. If you reverse the order you'll have the opposite problem, you can pick the item up, but you can't put it down.


[QUOTE=sman118]I really appreciate the help. Also, if you could friefly explain what you did, that would help me learn it for next time. Thanks![/QUOTE] He's effectively doing what I wrote in my post.inkBot2012-11-21 16:54:35
B
73
S
20
G
10
Posts: 524
Reputation: 9,896

Next

Return to How do I....?

Who is online

Users browsing this forum: DemantDigitalArt, Justin1967, Lancifer and 30 guests