# How do I detect collision coordinate of 2 round objects?

Get help using Construct 2

### » Sun Sep 04, 2016 1:06 pm

Hi,

I have 2 round objects, A and B. Object A will move towards object B in a bullet behaviour. I want the object A to stop immediately on collision with object B. I am thinking of getting the collision coordinate so that I can set the position of object A. What is the best way to detect this precisely? Or any other approach that's better?
B
23
S
10
G
2
Posts: 104
Reputation: 3,071

### » Sun Sep 04, 2016 1:12 pm

If they are the same size:
a.x+cos(angle(a.x,a.y,b.x,b.y))* distance(a.x,a,y,b.x,b.y)/2
a.Y+sin(angle(a.x,a.y,b.x,b.y))* distance(a.x,a,y,b.x,b.y)/2
B
178
S
50
G
206
Posts: 8,685
Reputation: 127,713

### » Sun Sep 04, 2016 6:38 pm

B
11
S
6
G
15
Posts: 256
Reputation: 9,207

### » Mon Sep 05, 2016 12:04 am

Thanks for the replies!

@Gmoney @newt

I tried your expression but it doesn't give the result I want. As in, sometimes it will be off by a few pixels. Does the collision polygon affect the results? The objects are different sizes.
Last edited by mrneko on Mon Sep 05, 2016 7:19 am, edited 1 time in total.
B
23
S
10
G
2
Posts: 104
Reputation: 3,071

### » Mon Sep 05, 2016 2:11 am

They aren't the same size.

Just use the position the object had on collision....
B
178
S
50
G
206
Posts: 8,685
Reputation: 127,713

### » Mon Sep 05, 2016 2:34 am

@newt

I tried that but sometimes the ball went further in. I guess it's due to collision polygon. The ball is round but there are only 8 collision points. I am guessing certain collision area is within the ball perimeter and thus it stopped slightly later. Do you have a solution to this? Not sure if adding more than 8 collision points is a good idea but that's the only solution I can think of.
B
23
S
10
G
2
Posts: 104
Reputation: 3,071

### » Mon Sep 05, 2016 7:20 am

I found the solution. Basically I just use a dummy sprite to get the angle between the two balls and set the position towards that angle. Thanks for the tips guys.
B
23
S
10
G
2
Posts: 104
Reputation: 3,071