Collision Shapes are sometimes totally off (SOLVED)

Hi there,

I am new to the Defold Engine (like it very much so far) and following the “Getting Started”-Tutorial presented to me in my Dashboard.
(I am using the Preview Version of the Defold 2 editor.)

At Step 6, where we set up Ground Physics and Collisions, I am stuck because I get collisions where I shouldn’t get one.
Thanks to another Forum Post I figured how to enable “Debug” and thanks to that, I saw, that the Collision Shapes of the hero and the platform_long are strangely off from where I set them in the editor.

This is how I’ve set the Shapes in the editor:


And this is how they are presented ingame:

The small platform seems fine, but everything else is somehow totally off.
I tried to fix it for some time and figured, if I position the platform_long with the center of the left part at X = 0, it fits also ingame:

Is this a bug or is it intended behaviour and I don’t understand the editor?
Any help is very appreciated :slight_smile:

~ Daniel

No, this is not right. Though you’re using editor 2 so may somehow be related to that. Try downloading a copy of editor 1 and open the project in it?

Could you zip the project as is and upload it somewhere like dropbox?

This looks really strange. What’s surprising is that for the short platform the collision shape is in the correct position. I would have expected all or none to be offset.

As @Pkeod suggested please zip the whole project, or if it’s created from the Defold Dashboard then go ahead and invite me (bjorn.ritzl@king.com) so that I can take a look.

Thanks for your answers!
I just tried in editor 1, but the result is exactly the same. :frowning:

I uploaded the zip of the project to Google Drive: https://drive.google.com/open?id=0B-zbOuqFaKh-UXVjSzVNLTh0R0U

1 Like

Weird, apparently the collision object components are not keeping their offset. If you set the position of the collision object components to 0, 0, 0 and move the shapes into the right positions then it is fine. The short platform worked correctly because its collision object was already at 0, 0, 0. It must be a bug.

[edit] Oh, collision object components don’t have a position in Editor 1 . . . maybe the bug is that position and rotation are being used at all in Editor 2. (like it does with script components)

1 Like

Oh, wow, yes, collision objects do not have a position or a rotation in Editor 1. This is a pretty serious discrepancy between the two editors. @Erik_Angelin, @Ragnar_Svensson, @Ragnar_Dahlen and @mats.gisselson, your thoughts?

1 Like

Yes, that’s precisely the issue, sorry about that! I added it here: #713.

2 Likes

Thanks Ragnar. @multicoderdev: The solution is to not modify the collision object position and instead manipulate the collision shape positions to align them with the sprites.

Thank you all very, very much for your effort!
You are indeed very, very helpful! :slight_smile: Thank you!

3 Likes

My collision shape is off too.

The only thing that have attributes is the “go” that have an x of 360. It looks like the sprite gets dubble transforms. Once from the “go” and then again from the “collisionobject” or something like that. It doesn’t feels right to me, but it is this the expected behavior?

Hmm, that looks weird. I’m guessing that the collision object is dynamic? Dynamic collision objects attached to a game object will override any position set by either scripts or as a result of the game object being added as a child of another go (as is the case in your example where go1 with the collision object is a child of go).

Yes, the object is dynamic. I start with this collection, so there are no scripts running, what you can see in that collection is everything in the scene. I know it overrides the position and that you can only effect it by force, but shouldn’t that mean that even if it changed position of its parent go shouldn’t that also effect the sprite? Does it effect it twice?

Does this mean that you can’t have an offset for all your dynamic objects but most have all parents zeroed out and only set the position on the direct object?

In your situation, with a game object - with a dynamic body - set as a child to another game object, it won’t work as you might think. The sprite component on “go1” will inherit the transform from both “go” and “go1”, as you would normally expect, but “go1” is moving independently, rather than keeping its local position like a normal child. It means if “go” is moved from (0, 0) then the sprite will be offset from it’s parent, “go1”.

Basically you don’t ever want a G.O. with a dynamic body to be the child of another G.O…

3 Likes

Thanks for the clarification, it works like I thought then :slight_smile:

3 Likes

Hi there. Sorry for bumping this thread, I just wanted to know how can I preview the collisions like on @multicoderdev’s screenshots? Thanks

In the game.project you need to enable the physic debug.

2 Likes

Check the Debug checkbox in the physics section of game.project or post a toggle_physics_debug message to the system socket.

2 Likes