How do I Pin a sprite to another sprite on one axis only?

Get help using Construct 2

Post » Thu Apr 21, 2016 9:34 am

Is it possible to pin a sprite on one axis only?
So that it moves along one axis with the parent sprite but is free to move along the other freely?
B
7
S
1
Posts: 18
Reputation: 423

Post » Thu Apr 21, 2016 10:01 am

system > ever tick | objPinnedSprite > set position x= objOtherSprite.X

for Y you take whatever you like (eg. Mouse.Y)

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Thu Apr 21, 2016 10:05 am

Thanks, I tried this however the Y axis in this case is being controlled by physics and when I do this I get sporadic results.
I need to find a non intrusive way to pin the pinned sprite to the x axis of the other sprite so that the physics on the y axis are retained
B
7
S
1
Posts: 18
Reputation: 423

Post » Thu Apr 21, 2016 10:08 am

here i would try a helper Sprite (invisible) that has the physics behaviour attached
Now you can set position of your visible Sprite to .... (see example above only the other way arround)

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Thu Apr 21, 2016 10:18 am

Thanks again, I tried this also.. as well as attaching the physics and the movement together to the visible sprite.
On both occasions the re-positioning of the x axis from the movement seems to interfere with the physics engine and the sprite ends up moving erratically away from its location as it attempts to complete it's own repositioning
B
7
S
1
Posts: 18
Reputation: 423


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 17 guests