# Precise Rotating + Pin Behavior

Get help using Construct 2

### » Mon May 06, 2013 7:08 am

Hey Everyone,

I've been struggling with this one and any help is appreciated.

I'm trying to create a puzzle game where there are pieces on a board/grid that are influenced by gravity(towards bottom of screen). I want to be able to rotate the board/grid (90 degs at a time) with all of the pieces maintaining their relative position. Once the board has stop rotating, the pieces should fall according to the gravity (still towards the bottom of the screen even though the board has rotated).

I have 2 issues:
1. Is there an easy way to rotate an object using the Rotate behavior until it reaches an exact angle? Since I am rotating 90 degs at a time, I need it to be precise. I think I created a good work around but it may also be causing my second issue.

2. I am pinning the pieces to the board when I rotate it, then unpinning them when they need to fall towards the bottom of the screen. However, I can not get the pieces to remain preciously where they should be relative to the rotating board as it rotates. They seem to always want to slip slightly to the left and this causes problems with alignment.

Here is a link: https://www.dropbox.com/s/yn3f2ce4ntwfr7s/Rotate_Pin_Unpin.capx

Let me know if you have any suggestions.

Thanks!
B
10
S
1
Posts: 5
Reputation: 1,395

### » Mon May 06, 2013 10:08 am

Hi, not got much time at the moment but the first thing i see is your Blue blocks are 258 x 258 which means the image point is in the wrong place.

Will check out the rest later if no one else gets there first
B
43
S
15
G
9
Posts: 1,096
Reputation: 10,988

### » Mon May 06, 2013 10:51 pm

@spongehammer

Thanks for taking a look!

I did mess around with image point a bit but it seems like the piece still shouldn't move like it is. If the image point is off center then it will rotate a little oddly but the image point should always remain the same distance from the center of rotation.

I'm actually surprised I'm having as much trouble with this as I am. I thought this would be pretty straightforward, but I'm still new to Construct so I'm wondering if I'm missing some really obvious thing.

Thanks.
B
10
S
1
Posts: 5
Reputation: 1,395

### » Mon May 06, 2013 11:08 pm

As far as i can see there is nothing wrong with your logic. The pin behavior may not be accurate enough.
Also the detection you are relying on is not ideal either. Part of the problem is that if anything is out on the first rotate then its all compounded from there.

I would suggest a different approach to moving the blocks, more like moving each one a set distance from the center of the current square to the center of the next. This will do away with relying on the collision detection.

When i get a few mins free i will make a capx to show what i mean.
B
43
S
15
G
9
Posts: 1,096
Reputation: 10,988