How do I pin an object to a specific image point?

Get help using Construct 2

Post » Sat Sep 23, 2017 9:56 am

Hi,
I have a player animation with diffrent imagepoints for its hair, glasses and so on.
On creation I spawn the objects (hair, glasses and so on) at the corresponding image point and then I pin it to the playeranimation.

However the player animation, well is an animation and the image points are on diffrent positions at each frame.
So my question is, is it possible to pin an object to the image point? So if the image points moves while playing the animation, so that the pinned objects follow the image point?

@Ashley is this even possible with the Pin behavior?

Edit: Found out that @rexrainbow already made such a behavior, thanks man!

Thank you!
Image Image iTunes: Match3 | Google Play: Match3
B
109
S
39
G
31
Posts: 1,175
Reputation: 29,314

Post » Sat Sep 23, 2017 11:01 am

There is a behaviour called pin+ which have a ton of pin options and pin to image point is one of them. Just select which image point and it will pin it correctly wherever that image point is on the object during an animation.

I use this behaviour for all my games now and is one of my most used plugins.

viewtopic.php?f=153&t=190203&hilit=+pin

You can also pin animation, mirror, scale, opacity and best of all. You can automatically destroy the pinned object if the object it is pinned to is destroyed which makes the original pin behaviour useless in comparison :P Highly recommended
B
58
S
25
G
14
Posts: 793
Reputation: 13,302

Post » Sat Sep 23, 2017 11:14 am

@AndreasR


if I remember correctly the Pin behavior is the same as Every Thick set position, so wouldn't be easier to do?

Every Thick: object1 >>Set position to (base_object) image point 1
like this doesn't matter where you place the image point in different animations as long that animation has the image point will be placed on the correct spot
B
41
S
25
G
87
Posts: 309
Reputation: 48,096

Post » Sat Sep 23, 2017 12:03 pm

tarek2 wrote:@AndreasR


if I remember correctly the Pin behavior is the same as Every Thick set position, so wouldn't be easier to do?

Every Thick: object1 >>Set position to (base_object) image point 1
like this doesn't matter where you place the image point in different animations as long that animation has the image point will be placed on the correct spot


Hi,
I actually did that before. However when the player moves fast, the pinned object laggs after it.
But it also happens with @rexrainbow behavoir PinToImagePoint.

I'll try the Pin+ behavior, maybe this works.

Or has anybody an idea how to prevent the pinned object from lagging behind?
My player object hast the platform behavior. And when it starts moving, the pinned objects are lagging behind...
Image Image iTunes: Match3 | Google Play: Match3
B
109
S
39
G
31
Posts: 1,175
Reputation: 29,314

Post » Sat Sep 23, 2017 12:08 pm

Anonnymitet wrote:There is a behaviour called pin+ which have a ton of pin options and pin to image point is one of them. Just select which image point and it will pin it correctly wherever that image point is on the object during an animation.

I use this behaviour for all my games now and is one of my most used plugins.

viewtopic.php?f=153&t=190203&hilit=+pin

You can also pin animation, mirror, scale, opacity and best of all. You can automatically destroy the pinned object if the object it is pinned to is destroyed which makes the original pin behaviour useless in comparison :P Highly recommended


Hi,
thanks for that hint, I'll try out this one ;)

Thank you!
Image Image iTunes: Match3 | Google Play: Match3
B
109
S
39
G
31
Posts: 1,175
Reputation: 29,314

Post » Sat Sep 23, 2017 12:14 pm

Ok I figured something out.

I have a rectangle sprite as player (for collision box). This object has the platform behavior.
To this object I have pinned the player animation (another sprite object). This object is not lagging behind.

So to the player animation I have pinned the accessories, like glasses, hair and so on to its corressponding image point.
This objects are lagging behind, because the aren't pinned to the actually moving object.

If I pin them to the player object having the platform behavior, those objects also stop lagging behind.
Any ideas why this is happening?

Edit: Made an example
https://www.dropbox.com/s/sgp3iaustgamk ... .capx?dl=1
Image Image iTunes: Match3 | Google Play: Match3
B
109
S
39
G
31
Posts: 1,175
Reputation: 29,314

Post » Sat Sep 23, 2017 2:45 pm

@AndreasR
I think what happens is that your "Player is on screen" event is triggered first on start of the tick, before the Pin behavior does its job.
You set position of Hair to the PlayerAnimation sprite that hasn't moved yet. After that Pin behavior adjusts PlayerAnimation position to Player sprite, and the Hair stays behind (lags).

If instead of pinning PlayerAnimation to Player, you do "PlayerAnimation Set position to Player" (the same as you do with hair), then there is no lag.

You should use either Pin behaviors, or "Set position" actions, not the combination of both.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
71
Posts: 1,063
Reputation: 38,689

Post » Sun Sep 24, 2017 5:00 am

dop2000 wrote:@AndreasR
I think what happens is that your "Player is on screen" event is triggered first on start of the tick, before the Pin behavior does its job.
You set position of Hair to the PlayerAnimation sprite that hasn't moved yet. After that Pin behavior adjusts PlayerAnimation position to Player sprite, and the Hair stays behind (lags).

If instead of pinning PlayerAnimation to Player, you do "PlayerAnimation Set position to Player" (the same as you do with hair), then there is no lag.

You should use either Pin behaviors, or "Set position" actions, not the combination of both.


Hi @dop2000

I got it working now. I set the position of the player animation to the player every tick, but I pin the accessories to the player animation.
Now it doesn't lag afterwards!
Thanks for the hints!

Regards
Andy
Image Image iTunes: Match3 | Google Play: Match3
B
109
S
39
G
31
Posts: 1,175
Reputation: 29,314


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests