Create a circular collision polygon

0 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I'm making a game in which a ball bounces off solids, the angle of reflection needs to be perfect. Think pong, or the app Ballz. I cant find any other way than using the default 8 point collision polygon that the sprite editor generates for it. I would use more points but that would be resource intensive and i don't know if could make it a good enough circle without using a lot of points. Are they any work arounds? I've also been trying to use the physics behaviour because it has a circle collision mask option, and i tried setting its elasticity to high, density to 0 etc, in attempts to simulate the ball but with no luck. Sorry if there's already been a post about this, i couldn't find it and believe me i looked. Any help appreciated.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Use math. You need 2 things. 1 bar and 1 middle piece.

    Decide what Radius you want.

    On start of layout create bar

    repeat x179

    Set bar position to:

    X = middle.x + radius*cos(self.IID*2)

    Y = middle.Y + radius*sin(self.IID*2)

  • MPPlantOfficial

    Could you elaborate? So you create a circle with 179 bars. What's next? Use these bars to detect collisions and then calculate the reflection angle?

    You can do the same without the bar sprite.

    On collision with an obstacle check 180 or 360 times if obstacle is overlapping a point at (ball.x + radius*cos(loopindex), ball.Y + radius*sin(loopindex))

    There may be difficulties with both methods. What if the ball hits a corner?

    Another option would be setting "Bounce off solids=Off" and using Raycast plugin to determine the reflection angle. Although I don't know if it has been ported to C3 yet.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)