Circular collision shape with object inside

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By vbdev

Hi everyone,

I am new to godot (and in game development). I am trying to develop a ball maze puzzle game in which one or multiple balls will rotate inside a maze and according to device’s orientation they change the direction. The aim is to move all the balls in innermost circle; similar as the game mentioned in link below.

I have used ball as rigid body & maze as static body. Ball has circular collision shape. For maze I have used Create CollisionPolygon2D Sibling to automatically generate the collision shapes. I am facing following issues:

  1. The major problem is with the outermost circle, which is a closed circle. The generated collision shape covers the whole inside area. I cannot place ball inside it, if tried, the ball is shown outside the maze at run time. What can be done to make a circular unfilled collision shape.

  2. Secondly, the generated collision shapes are not perfectly circle (nor polygon). I tried by decreasing the Simplification factor, but still instead of a polygon-like shape, there are zigzag lines (only vertical & horizontal segments, no slanted segments). Is there any other way or we have to edit the points manually only?

Please have a look at this game: Ball Trap - Roll the Ball

Thanks!

:bust_in_silhouette: Reply From: Tato64

To make a circular unfilled collision shape, try making half of it with a CollisionPolygon2D and then just duplicate and rotate that to “complete” the unfilled circle, you can put them both as children of a StaticBody2d if you need them to rotate together or something.

Not sure how can i help about the second one, tho.

Hope this helps!

Thank you very much for your fast reply.

As my sprite has multiple shapes and I was using Create CollisionPolygon2D Sibling, I was getting multiple collision shapes; one for each shape in the sprite. That led me to conclude that every shape in the sprite should have a single collision shape. I didn’t thought that I can use multiple collision shapes for a single sprite shape, thanks for the hint !!!

In the meanwhile after posting this question, somehow I solved the problem. Here is what I have done (it may help somebody):

First of all, I downloaded a radial graph png file, & added it as background (temporarily)

Previously, my sprite had thick walls for the circular shape. So I started making the collision shape manually from inner side of the shape. I placed each point at 10 degrees. After reaching near the start point, I switched to outer side, reversed the direction & completed the whole shape. Later on I edited the start & end points such that there is no gap between them.

Next instead of using thick walls, I wanted to use circle with no (or little) stroke width. So I tried the same way, but now instead of marking the points at 10 degrees, I marked 20 degree points in one direction & other 20 degree marks in the revers direction. Now my collision shape was built, but after testing I noticed that the ball was passing through the shape.

So I reached to the conclusion that the collision shape must have a filled area to work properly. But then I tried to change thhe Build Mode from Solid to Segments & my problem was solved!!!

vbdev | 2021-04-15 07:40