godotengine / godotengine/godot

`CharacterBody*D.get_gravity()` only considers changes to area overrides when moving

Open
#112,656 8 comments 0 reactions 0 assignees View on GitHub
bug confirmed topic:physics
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Godot 4.5 stable

### System information

Windows 10 - Godot 4.5 stable

### Issue description

CharacterBody3D.get_gravity() does NOT take account of the gravity settings in overlapping Area3D.

1. Just create a scene and put a CharacterBody3d with a CollisionShape into it. Without anything else, its get_gravity() returns (0, -9.8, 0) which is the default gravity setting in the project;
2. Now add an Area3D with a CollisionShape which overlaps with the character. Set Space Override in Graivty for the Area3D with another value;
3. You will find get_gravity() still returns (0, -9.8, 0) which doesn't match what document says;
4. Now change the character type to RigidBody3D, observe get_gravity() again, you will find the result is the combined calculation of project setting and area setting. It matches what document says.

Link to the document:
https://docs.godotengine.org/en/stable/classes/class_physicsbody3d.html#class-physicsbody3d-method-get-gravity

### Steps to reproduce

See issue description.

### Minimal reproduction project (MRP)

N/A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.