Fix collison detection for 3D (and seperate objets)

The “is Object1 in collision with Object2” Currently just detects if an object is inside/touching another object but only on the X and Y axis but not the Z axis, thus making it hard to detect if an object is actually in collision with another.
another reason this is needed to be fixed is that you have to do all this math to detect if a player is on a certain floor or not like i am making a 3D Jumping Extention and the way it works is you give it a pre-defined floor Z height, and for my example game, can jump on top of walls, so i have to tell it if player Z is above 20 and below the next wall (like could be 40) then set floor Z property to 20 allowing for the player to go though i guess ( i forgot what i was saying like half way thru this paragraph)
also another thing that needs to be fixed is separate objects (could also simplify my extension ALOT)

1 Like

Yeah I agree. Also topdown behavior needs to have its own way of collision. Doing “separate objects” is glitchy when I use it. And when you make a sprite rotate it moves the character. And if your moving on the object. You go slightly through it. Making where if you have let’s say. An object for hand. Another for the character. To have it easier cuz they’re separate. The hand moves weirdly while doing so. I think topdown wasn’t implemented very well with collision. I would just make the player a platformer object with all behavior settings set to 0 and with platforms. A platform object. And I think that does the job better

Also. Collision was the deadend of me making my game with that as one of the limitations

I’m guessing this will be implemented at a later stage. In the mean time, you’ll probably have to do it yourself. It’s not that hard - check for standard collision, and then use a simple check to determine if there’s an overlap in the z-axis for both objects.


Pseudo code for the check for collision along the z-axis:

> (obj1.zorder <= obj2.zorder + obj2.height) and (obj1.zorder + obj1.height >= obj2.zorder)

[correction, it should be the z position, not the z-order]

(obj1.z <= obj2.z + obj2.height) and (obj1.z + obj1.height >= obj2.z)
This will be true if a collision occurs.


Then you’re not doing it right, because other top-down games don’t have this problem. Don’t blame the tools if you aren’t using them properly.


Programming is all about working within limitations and eeking the most out of the system. You have to work out how to get the end goal with those limitations and restrictions. That is the art of programming.

I can code make my own extension for it but it would be kinda scuffed and unofficial

You can create your own extension just for your project that you wouldn’t have to share if you don’t want to. Many GDevelop devs do that.

well i tried to do it and it wont work soooooo

Create another topic asking for help with the extension. Include a screen snip of what you’ve got so far, what it does (and doesn’t) do, and what you’d like it to do. I haven’t spent a lot of time with extensions, and there’ll be others who have and can help.

for some reason i have an object on a 3d scene and if the camera is in collision and separates. i can go slightly through the cube and when i release the walking key i am forced back like 10 pixels, i had a test project. it worked right, when i try it on a particular object on my main thing it does not work right edit: here’s a video to show what I’m talking about Collision Glitch - YouTube

What you are experiencing is likely that GDevelop is at its limited on how fast it can run the events, and are you using the built-in push object away or not? If you are not using the built-in move, objects way, and you are using it, the collision detection math, that the other user gave you switch the operator signs to not be thy or equal to one’s that will emulate the setting in the official collision detection to ignore touching edges. That may work it may make it worse, but might as well try.

I am using the normal, “separate objects” action. Something I did realize while testing on a test project. The first person camera extension had it happen. So I looked at some 3d examples and they don’t use it and it worked. So by then I thought I figured it out. It even worked on the test project. But didn’t on the project I want it to. Maybe there’s a sneaky event that’s causing it. But I disabled alot and it didnt work

But also. Sometimes it doesn’t only do it for the camera. But for the player object too. So I’m not sure what’s happening. I also tried just using the separate objects action without any condition,

Nevermind. After some trial and error I finally figured it out