Restrict object position to a circle

Get help using Construct 2

Post » Thu Jan 30, 2014 2:10 pm

So, let's say I have a circle

o

How do I make another object set it's position to the edge of the circle, relative to my mouse position?TwinTails2014-01-30 15:37:05
B
25
S
6
G
3
Posts: 197
Reputation: 3,355

Post » Thu Jan 30, 2014 2:17 pm

Let's call A = angle(center of the circle,mouse)
Then you have the coordonates for your object with some trigonometry.
X = cos(A)*D/2
Y = sin(A)*D/2

Where D is the diameter of the circle.
B
17
S
8
G
4
Posts: 473
Reputation: 6,191

Post » Thu Jan 30, 2014 4:05 pm

@Guizmus Thank you, very helpful! Had to tweak a little but it worked like a charm
B
25
S
6
G
3
Posts: 197
Reputation: 3,355


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], Lightstone and 27 guests