Game-settings to use physics from topview

Hey there.

I want to use the physics for a top view game. How to do? What to change? The camera angle? the gravity-vector?

Changing the camera position seems more reasonable. If you don’t need 3D physics, you can just set the gravity to 0, that’ll make the same effect.

1 Like

I am talking about a 2D game. I want to use the physics f.e. hitting an object this object will be moved by the force of impact.
Or imagine you’ll throw a granade and at the explosion-point all objects around will be moved away depending on the force/explosion of the granade.

All viewed from top. no sidescrolling (this seems to be the standard at defold).

Simply set the gravity to 0? But what if I want to have a gravity in Z?

Just set the gravity to zero, that’s it. You probably also want to set the linear damping on your objects to something above zero to simulate friction (if they are sliding or rolling on the floor).

1 Like

Speaking of physics explosions, here is a great tutorial on three methods, increasing in complexity and realism. This guy also has a ton of other articles/tutorials on physics stuff if you’re interested. (though Defold only has a small piece of Box2D’s full capability.)

2 Likes

If you want gravity in Z it’s not really 2D physics anymore, right? Which means Box2D is not the physics engine to use. Defold had another 3D physics lib implemented before (bullet?) but I think they stripped that one out a while ago.
I would suggest you either: write your own “fake physics”. I would recommend it. It gives you a lot more control over whats happening or at least use Box2D on the visual horizontal and vertical plane and write fake physics for your Z.

1 Like

Bullet is still in there, but I haven’t played around with it.

Thanks for your answers.

Why write new physics?
Physics are working fine for a sidescroller IMO.

I cant see a reason why it shouldn’t work for topview? Simplified its just another angle of viewing. Turning of the gravity may solve this or not?

There are a lot of top viewed shooting games where you fire a rocket, throw a nade, running against boxes etc and the object will move depending on the force or impact. Driving a car into another car…the impact an moving of the crash is physics which should work already - or not?

I took a quick look at the link of ross.games. Using raycast may be a way but why create something new which is already there?

It’ll definitely work. You were mentioning wanting to use the 3’rd dimension and that would complicate stuff if the 3D lib wasnt still there. But as Sicher says, it’s still there so I guess in the game.project you just change Type to 3D and then gravity_y to 0. (if you want gravity in z then you just change gravity_z).

Then if physics is the way to go every time on a sidescroller… that we could discuss another time :slight_smile:

1 Like