Pin an object to a moving imagepoint ?

Get help using Construct 2

Post » Sat Oct 24, 2015 2:25 pm

Hi.
I want to stuck a moveable hat on my character. My character has an imagepoint "head" which is different for each animation frame.
I want my sprite hat always beeing on this imagepoint regardless the animation frame.

I tried the simplest way, as a each tick -> set hat position to character imagepoint
But it doesn't work as the hat is always 1 frame late and seems to "follow" the head instead of beeing pinned on it.

Actually I'm using this :
each tick ->
  • hat Pin Unpin
  • set hat position set hat position to character imagePoint
  • hat Pin pin to character

It does the trick but seems ugly to me.

Is there a more proper way to achieve this ?
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sat Oct 24, 2015 3:11 pm

not tried but how about

head - on frame change --- unpin hat
--- position hat on object image point "Hat"
--- pin hat

?
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Sat Oct 24, 2015 3:16 pm

I recommend rex's pin to imagepoint behavior. It's quite simply excellent.
A big fan of JavaScript.
B
76
S
20
G
74
Posts: 2,249
Reputation: 46,472

Post » Sat Oct 24, 2015 3:16 pm

@Coin-coin le Canapin

Have you tried it without the pin behavior?
I see no reason to use that if you set the position every tick.
B
24
S
3
G
1
Posts: 454
Reputation: 2,171

Post » Sat Oct 24, 2015 3:30 pm

@RamPackWobble : Didn't thought about this condition ! I'll try it.
@Colludium : I prefer not using external plugins or behavior if I can achieve something easily, but I will take a look at it !
@Asmodean : I tried and I mentionned it. :)
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sat Oct 24, 2015 3:58 pm

Coin-coin le Canapin wrote:I tried the simplest way, as a each tick -> set hat position to character imagepoint
But it doesn't work as the hat is always 1 frame late and seems to "follow" the head instead of beeing pinned on it.


If you add a wait(0) seconds action before the set position, or put the event after the events changing the position/frame of the sprite this should work..
(Construct2 reads events top to bottom)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Oct 24, 2015 5:08 pm

It doesn't work. Finally I used rex's behavior as it is quite straightforward.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sat Oct 24, 2015 6:20 pm

too late again - but here is my test of above - appears to work but with simple movement. Nothing wrong with using plugins - there are many excellent one available to us.

https://goo.gl/wSOiDy
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892


Return to How do I....?

Who is online

Users browsing this forum: YoHoho and 13 guests