summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/editor
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2023-11-08 16:56:19 -0600
committerAaron Franke <arnfranke@yahoo.com>2024-01-30 23:57:38 -0600
commitaed5ea946036e6c2c8a0165265bb6b038b3db8cb (patch)
tree97c2e825533617a2c3b12a45e6c5a09e06886b0b /modules/gdscript/editor
parent313f623b9d102cc8c411ae7cab9518f98c2f87f2 (diff)
downloadredot-engine-aed5ea946036e6c2c8a0165265bb6b038b3db8cb.tar.gz
Expose a method to get gravity for any physics body
Diffstat (limited to 'modules/gdscript/editor')
-rw-r--r--modules/gdscript/editor/script_templates/CharacterBody2D/basic_movement.gd5
-rw-r--r--modules/gdscript/editor/script_templates/CharacterBody3D/basic_movement.gd5
2 files changed, 2 insertions, 8 deletions
diff --git a/modules/gdscript/editor/script_templates/CharacterBody2D/basic_movement.gd b/modules/gdscript/editor/script_templates/CharacterBody2D/basic_movement.gd
index 28ab080dd2..bd4816827f 100644
--- a/modules/gdscript/editor/script_templates/CharacterBody2D/basic_movement.gd
+++ b/modules/gdscript/editor/script_templates/CharacterBody2D/basic_movement.gd
@@ -6,14 +6,11 @@ extends _BASE_
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
-# Get the gravity from the project settings to be synced with RigidBody nodes.
-var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity")
-
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
- velocity.y += gravity * delta
+ velocity += get_gravity() * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
diff --git a/modules/gdscript/editor/script_templates/CharacterBody3D/basic_movement.gd b/modules/gdscript/editor/script_templates/CharacterBody3D/basic_movement.gd
index 9b0e4be4ed..f9c4f70a24 100644
--- a/modules/gdscript/editor/script_templates/CharacterBody3D/basic_movement.gd
+++ b/modules/gdscript/editor/script_templates/CharacterBody3D/basic_movement.gd
@@ -6,14 +6,11 @@ extends _BASE_
const SPEED = 5.0
const JUMP_VELOCITY = 4.5
-# Get the gravity from the project settings to be synced with RigidBody nodes.
-var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")
-
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
- velocity.y -= gravity * delta
+ velocity += get_gravity() * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():