How do I detect the collision of a ring with small gap?

Get help using Construct 2

» Fri Feb 27, 2015 5:04 pm

Hey there,

I want to make a ring and detect if an object hit the outside of it.
The ring also has a small opening/gap where a bullet shall fly through and move on the inside of the ring.

Is the only way to achieve a correct hit detection the polygon tool with many many points or do you guys have some suggestions for me?

TLDR:
How can I achieve to hit detect only the ring shape itself?

Best regards!
B
6
S
2
G
3
Posts: 9
Reputation: 2,252

» Fri Feb 27, 2015 8:42 pm

..only with ring and half ring
You do not have the required permissions to view the files attached to this post.
B
57
S
23
G
7
Posts: 1,429
Reputation: 10,512

» Mon Mar 02, 2015 12:55 am

Thanks for the fast and nice reply even with example!
I had the same idea so far with a not so well made polygon shape to do the job somehow. But isnt there any other way which is more clean and precise?
B
6
S
2
G
3
Posts: 9
Reputation: 2,252

» Mon Mar 02, 2015 2:14 am

You could do your own collision detection with some math if you want it to be very precise.

In the attached capx it does point vs ring with gap collision detection.
The idea is you can find if a point overlaps the ring if the distance from the point to the center of the ring is between the inner and outer radius' and if the angle from the center of the ring to the point is not within half the angle width of the gap from the current angle of the gap.

Like most math like this it makes more sense if you draw a diagram of it.
You do not have the required permissions to view the files attached to this post.
B
82
S
26
G
63
Posts: 4,857
Reputation: 45,754

» Mon Mar 02, 2015 2:34 am

Dear R0J0hound,
this is absolute amazing!
This is absolutely what I was trying to get but couldnt achieve!
I am so thankful!

I tested it and it looks awesome, cant figure out your few lines of math which do the magic but i get into it.
Thanks again!
B
6
S
2
G
3
Posts: 9
Reputation: 2,252

» Sun Mar 15, 2015 5:46 pm

@Solano
Here's the capx I used to make the ring image. It uses the Canvas Plugin.
You do not have the required permissions to view the files attached to this post.
B
82
S
26
G
63
Posts: 4,857
Reputation: 45,754