# [Done!]Objects in Circle Glide to Position

Get help using Construct 2

### » Mon Oct 07, 2013 3:54 am

This is what I have so far, in a little video here.

If you watch, as I click the blocks, they disappear and the other blocks take their place. This is because I have it set to calculate the position that each block should by:

1. Taking 360 and dividing it by the number of blocks
2. Positioning the blocks at the specified angle away from the little green center block
3. Calculate distance from the block using Trigonometry.

Right now, I'm keeping track of every block using arrays, since technically they are all one kind of object, but have different properties.

So what I would like are suggestions as to - instead of having the blocks suddenly take their proper positions - making them glide to their proper positions in the circle when any one is removed.

I'm kind of at a loss for how to do it, so anything would be appreciated.DatapawWolf2013-10-09 06:17:14
B
62
S
19
G
51
Posts: 633
Reputation: 30,836

### » Mon Oct 07, 2013 4:01 pm

Sorry to bump but I'm surprised; no one has anything?
B
62
S
19
G
51
Posts: 633
Reputation: 30,836

### » Mon Oct 07, 2013 4:15 pm

I guess rotate toward angle would be a problem, because of the rotation already present?

I can not see by looking at your youtube video how you have the blocks set up and/or what your further plans are with the blocks once you have this working. It's hard to give advice on how to change something if you don't know where the cange originates.
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

### » Mon Oct 07, 2013 4:15 pm

I would use anglelerp(a,b,x), where a is the last angle the instance was at, b the new angle it has to be at, and x moving from 0 to 1 within a certain time. The latter can be done with a variable that you set on every tick while needed to
var = min(var + n * dt, 1)

(n being the amount you want var to raise per second)
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,289

### » Mon Oct 07, 2013 7:00 pm

I agree with tulamide regarding using anglelerp to move arrows to their new positions. The tricky part is moving each arrow the appropriate amount so the transition looks smooth.

Demo
Capx
B
67
S
20
G
8
Posts: 341
Reputation: 12,510

### » Mon Oct 07, 2013 7:40 pm

Actually, I would try and have each check to see if the one behind it is in place, and if not, slow it's rotation until it sees one in place behind it.

They should all self adjust that way, as soon as one slowed, the one in front of it would too.
B
252
S
65
G
34
Posts: 907
Reputation: 41,505

### » Tue Oct 08, 2013 12:18 am

Thank you all for the wonderful comments!

@LittleStain I agree. If I can't figure out a form using the other suggestions, I will definitely upload something to look over. :)

@tulamide I'd never had experience using linear interpolation before, so I will give it a shot. Thank you!

@Paradox I believe that is also a good suggestion, although, (and I know I don't have an example here) that may not work with the setup I have. I'll try Tulamide's suggestion first and go from there, for now.
B
62
S
19
G
51
Posts: 633
Reputation: 30,836

### » Tue Oct 08, 2013 12:30 am

How about on click they all rapidly shrink until they are too small to see, rearrange themselves, and then grow back to the original size showing the new positions. (that would probably also be a lerp, in size.)
B
252
S
65
G
34
Posts: 907
Reputation: 41,505

### » Tue Oct 08, 2013 1:16 am

Well, what I had in mind is actually keeping track of their angles individually using the array I already use for types and such.

Then I'll just update each position array element individually using AngleLerp like Tulamide said, and have that displayed on screen. :)
B
62
S
19
G
51
Posts: 633
Reputation: 30,836

### » Tue Oct 08, 2013 7:58 am

I did officially get linear interpolation working! Thanks @zatyka for the capx file. I did take one line from your project and it was the degree of interpolation. Wasn't sure what to put until I saw your project used dt and then I went "Oooooooooh..." Hahah. So I'll probably be tweaking that value as I go on.

Again @Tulamide thanks for the suggestion! That was exactly what I needed. :)

I'll be updating the screenshots thread with some more progress as I go on.

Finally, wish me luck using 3D arrays! ;)
B
62
S
19
G
51
Posts: 633
Reputation: 30,836

Next