Collision 2D Polygons To capture Mouse Input

I am evaluating Defold alongside GODOT and YoYo Gamemaker to design 2D games / sims.

GODOT has the ability to create rect and polygon 2D collision objects on top of sprites for later use in evaluating mouse inputs.

So far in my evaluation of Defold I haven’t found a similar functionality. Is there any intention to add it in the future?

Below is a screen print from GODOT showing collision objects overlaying the sprites.

You can actually use convex shapes for collision objects, although there’s no built in editor for them. Luckily forum user @ross.grams has actually also created a polygon editor for this exact purpose.

2 Likes

Yeah, Godot has Defold beat in this area with its automatic support for any polygon. You can do it with Defold, especially with the help of my polygon editor, but you’ll have to break each country up into convex polygons yourself, and add a collision object component for each piece. You can probably get away with simplifying your shapes a bit so most of them will only be one or two convex pieces. If you’re feeling gung-ho you could modify my editor to break it up automatically, I’m sure you don’t want to wait for me to get around to that eventually.

The other option is to build your own collision detection in lua, or find a library. You could check out this one: https://github.com/vrld/HC, it says it supports concave polygons. It would be pretty easy to adapt my editor to give you the plain array of 2D points that it needs.

Ragnar S. mentioned they might take a look at physics issues soon (and I’m sure he appreciates people taking every one of his words as a promise :P), but I don’t know if this will be prioritized, since it’s not a bug and there are workarounds. It would be nice at least if polygons were supported as an actual shape type instead of some weird property on collision object components.

4 Likes

Ok, thanks britzl.

Hi ross, I’m at the very early stage of developing a game. I’m really just trying to grasp what is possible, what is easy and what is more complicated. The UK election example above is just to discover how to use controls, sprites, canvas layers, collision objects, mouse events etc. I’m a business application programmer trying to port to game / sim programming ( which can lead to some bad assumptions).

I reviewed at least 12 game engines before deciding to focus on GODOT, Defold and Gamemaker. I find GODOT slightly more straight forward at dealing with objects but I prefer the way Defold handles script procedures, events and messages. GODOT also runs well under Ubuntu, my preferred OS. So I don’t think I am going to find everything I like in one engine. I’ll probably use different engines for different projects.

1 Like

@stephen7272 I would very much appreciate an honest side by side comparison of the engines once you have finished your evaluation, no matter which engine you decide to go with.

Defold should also play nicely with Ubuntu. Have you found any issues with Defold on Ubuntu?

Yes! Exactly! Defold is not a Swiss Army knife. We do not aim to be best at everything, but rather to be a really good choice for 2D game development. Sometimes another engine will be a much better choice than Defold, and we’re ok with that.

Gotcha, sounds good. I guess you found one of the more complicated things. :slight_smile:

I used Godot for several months before moving primarily to Defold. Godot is pretty nice and I agree its object system is more standard and easy to get used to. The things I don’t like are its smattering of bugs, its open-source-hodge-podge, quantity-over-quality design, and most importantly its poor script performance; which pretty much killed all my fast-paced action game projects once they started getting complicated.

1 Like

Defold should also play nicely with Ubuntu. Have you found any issues with Defold on Ubuntu?

Apparently it requires a JOGL lib which I don’t have installed on my machine.

Ah, yes, sorry… you mean this post: Defold error on opening tutorial