Am new to gd script

godot-4

	velocity.y+= gravity() * delta

thats the code am having issue with ,and the error finder or whatever in the bottom
Function “gravity()” not found in base self.
sorry am new to pc i swear

When you add a script to a CharacterBody2D it will add a gravity var at the to of the file.

# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")

Also, gravity is a variable, not a function.

velocity.y += gravity * delta
1 Like

How do i change the grivity with code

ProjectSettings.set_setting("physics/2d/default_gravity", 1.42)

That isnt working for me. this is my code

never mind i just saw that im using 2d gravity for my 3d game

double nevermind still not working

Weird;

Is pretty simply stating it changes the settings. I have never used that method, so I don’t understand why it wouldn’t work right out of the box.

What does it print if you used get_setting() right after the call, did it change it there?

The API has a save() but that is for external saving.