Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

How to create a perfect collision box around an irregular object
Started by benj.jones7 Oct 06 2019 08:35 AM

2 replies to this topic
hitbox collision
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Observer

  • 1 posts
  • Corona SDK

For the main 'character' of my game I have a BMX bike as a PNG, at the moment of its collison box I'm using a  rect. I need the hitbox to me more precise for the shape of the bike as at the moment it only balances on the square rectangle not the individual wheels.


I'm quite new to corona, any ideas as to how I'd manage to match the shape of the bike for my collision box.



[TOPIC: post.html]

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Corona Geek

  • 1,254 posts
  • Corona SDK

You can either create a physics object out of multiple elements, or create an outline or a chain body, or create multiple independent physics objects and put them together using joints.


One easy method for creating irregular shapes (through multiple elements) is a 3rd party software called PhysicsEditor. PE will let you create multibody objects with ease and then export them to Corona.




You can check the documentation for physics bodies and joints, or you could take a look at some Corona sample projects. For instance, start your Corona simulator, then press help > sample projects, and navigate to joints. You'll find a rudimentary "car" built using wheel joints there.

  • roaminggamer likes this

[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Contributor

  • 814 posts
  • Corona SDK

I use physics editor too.


@benj.jones7 should also check out texture packer by the same company when you are ready to use sprite sheets to save texture memory.


Also tagged with one or more of these keywords: hitbox, collision