# how can i set turret position in this example

Get help using Construct 2

### » Sat Jul 11, 2015 1:30 pm

hi
dropbox.com/s/qg05u1sw8ydic5i/prob.capx?dl=0
i have 72 frame of a tank rotating
i want my turret position always be in the back of the tank but i can not use imagepoints as you can see (it is so bad when i use imgepoints and turrets not always in the same place ) that must be so acurate to work and doing that for 72 frames and alot of objcts like that is not an option
so i need a formula
B
17
S
6
Posts: 245
Reputation: 1,784

### » Sat Jul 11, 2015 6:10 pm

no one know that ?!?!?!?!?!?
my project almost done i just stuck with this !
any suggestion?!
B
17
S
6
Posts: 245
Reputation: 1,784

### » Sat Jul 11, 2015 7:19 pm

if i know how to move an object in a isometric circle then i can solve that !
any one can help ?
B
17
S
6
Posts: 245
Reputation: 1,784

### » Wed Jul 22, 2015 9:17 pm

With the truck facing right the offset of the turret to the truck is (-13,-8).

Then you can set the position with
turret.x = truck.x -13*cos(360/72*truck.animationFrame)
turret.y = truck.y -8 -13*ratio*sin(360/72*truck.animationFrame)

Now "ratio" is the ratio from the visual height to the visual width of a isometric square. Depending on the angle of the isometric projection the ratio will be different. I was expecting 0.5, which is 26.5 for degree, but that didn't look right. So I measured the roof of the truck at 0 and 90 degrees. It was 8 pixels wide at 0 degrees and 22 pixels at 90, so the ratio is 8/22 or 0.36, so the angle is 20 degrees.

So you could write it like this:
turret.x = truck.x -13*cos(360/72*truck.animationFrame)
turret.y = truck.y -8 -13*tan(20)*sin(360/72*truck.animationFrame)
B
95
S
33
G
128
Posts: 5,491
Reputation: 81,570