Circle Collision Radius

Get help using Construct 2

Post » Sun Aug 05, 2012 8:13 pm

How do i adjust collision circle radius ? If it's not in yet, a good workflow: Instead of Set Collision Polygon on Sprite Editor change it to Set Collision Body. If it's a polygon set it like it is now. If it's circle mode adjust circle radius by distance between mouse and sprite center. If it's rectangle mode either treat it as a polygon and constrain adjusting to rectangle or treat it as a true rectangle in code. That would be a nice workflow imo. Kiyoshi2012-08-05 20:15:07
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Sun Aug 05, 2012 8:26 pm

Here is your answer ...
You need to make a mask ... and position it on the same position as the object and then ..
(Every Tick) : (Mask) : Set size to (distance(Mouse.X*2, Mouse.Y*2, Circle.ImagePointX(0)*2, Circle.ImagePointY(0)*2),distance(Mouse.X*2, Mouse.Y*2, Circle.ImagePointX(0)*2, Circle.ImagePointY(0)*2))
I hope it helps !kbdmaster2012-08-05 20:28:17
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Sun Aug 05, 2012 8:34 pm

Well you misunderstood :) That won't help at all, maybe for some other case. And it's editing the circle in edit time not runtime but thanks anyway :) And an observation : using dummy sprites for collision stuff is imo really bad. It's at max a temporary workaround. Avoid doing that if possible !Kiyoshi2012-08-05 20:38:37
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Sun Aug 05, 2012 8:44 pm

Oh , Well I am sorry !
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Sun Aug 05, 2012 8:48 pm

The reason we don't have a circle is because, well there's no such thing as a circle. It's either a bunch of points, which is highly unrecommended, or you use pythag IE distance(), which is not a great idea because it does not pick on its own.

I would suggest thinking less circle, and more poly, as in hexagon, or perhaps octagon.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Sun Aug 05, 2012 9:13 pm

@kbdmaster No need pal, the important thing is trying to help :D

@newt

You're closing your thinking in polygons. A circle in this case is just a point and a radius nothing more. It's the fastest and easiest to implement (circle X circle). That's why the ideal is the concept of a collision body made with sub parts. Each part can be a polygon or circle. That introduces substantial complexity yes, having to handle , polygon x polygon , polygon x circle and circle x circle. In the simplest mode. And having to adapt that to physics. That's why very few engines implement this properly.
Well for now octagons will do... Kiyoshi2012-08-05 21:19:08
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Mon Aug 06, 2012 8:28 am

Using a smaller object underneath just for the collision isn't so bad, only one extra object.
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Mon Aug 06, 2012 8:10 pm

You could have hundreds :)
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Mon Aug 06, 2012 8:26 pm

If you're talking about normal collision checking, like mouse clicks or sprite collisions, then I would check for a circle collision in the code triggered by a square collision. (IE, a square with 10 width would have a 5 radius, whenever the square collides it would then check for a radial collision from the center)

Although you're right, the image editor having a circle option separated from pixels could be a useful feature. But in terms of game efficiency, there's nothing wrong with resorting to octagons or manually checking its radius on collision.
B
19
S
5
G
1
Posts: 104
Reputation: 2,920

Post » Mon Aug 06, 2012 10:28 pm

You seem to already have the answer - just check if the distance between the coordinate you want to check and the center of the object is smaller than the circle radius - if it is, there's a collision.
if you want to check between two circles, the process should be very similar, and extremely simple as well: the distance between the objects should be less than the sum of their respective radii for a collision to happen.

If you need something else, try this:
Collision detection and reaction
it's made for AS3, but one with your knowledge level should be able to port the code easily :)Fimbul2012-08-06 23:07:48
B
35
S
8
G
8
Posts: 532
Reputation: 6,868

Next

Return to How do I....?

Who is online

Users browsing this forum: Colorfish and 2 guests