How would I do 2d planet gravity in a game

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By a human

I’ve made a kinematicbody2d that moves left, right, and collides (the player), and a staticbody2d that has a collision circle and an area2d (the planet and gravity field). I have the gravity set to a point, and I was wondering how I could get my player and a few rigid bodies to… you know, actually fall towards the planet. I am really new to Godot, so any help would be appreciated.

:bust_in_silhouette: Reply From: Dlean Jeans

Use RigidBody2D. It supports gravity by default and works with Area2D gravity properties. You may want to change the its Mode to Character so your character won’t fall flat.

Docs for enum Mode.

the rigid body doesn’t fall towards the planet I made though

a human | 2019-05-12 15:59

also how do i change its mode

a human | 2019-05-12 16:01

  • Select the Area2D and change it’s Space Override property to anything other than Disabled for the gravity to work.

  • Change the RigidBody2D mode in the Inspector with the body selected.

Dlean Jeans | 2019-05-12 17:26