How do I make a global gravity system?

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

I was wondering if I could use groups or custom resources to make a global gravity physics system in my 2D game so I could just call it in a script attached to a resource or a group and make all things have gravity as much as the player, enemies, objects, etc.

:bust_in_silhouette: Reply From: klaas

physics/gravity is allready global by default.
Have read through this?

When you create a rigid body it should receive the gravity force defiend in Project Settings->Physics->2d->Default Gravity

But how do I implement the same physics i used in a player to an enemy if both are kinematic body 2D?

SamStackz | 2021-07-12 19:29

have a look here …

Using CharacterBody2D/3D — Godot Engine (stable) documentation in English

What is a kinematic body?

KinematicBody2D is for implementing bodies that are controlled via code. Kinematic bodies detect collisions with other bodies when moving, but are not affected by engine physics properties, like gravity or friction.

so, you either have to change your player and the enemies to rigid bodies or you have to imnplement your own physics/gravity system.

klaas | 2021-07-12 19:33


SamStackz | 2021-07-12 19:44