The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

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!

Godot version 3.2.3
in Engine by (56 points)

1 Answer

+1 vote

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!

by (311 points)

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!!!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.