Godot Version 4.3
How do I change this
if not is_on_floor():
velocity += get_gravity() * delta
to where the gravity is a changeable variable?
Please and thank you
if not is_on_floor():
velocity += get_gravity() * delta
to where the gravity is a changeable variable?
Please and thank you
I think it uses the Gravity you have setup in your Project Settings.
You can also just use your own gravity value:
const GRAVITY = 9.8
func _physics_process(delta):
if not is_on_floor():
velocity += GRAVITY * delta
When I try to make a var or a const for gravity, this pops up
Shouldnt it be velocity.y += ? Velocity is a Vector2, so if you create a float and try and assign it as a value to a vector2 it doesnt work.
Or you make your gravity a Vector2 var.
Velocity.y += gravity * delta
2D physics gravity is defined in the project settings. The get_gravity
function returns a vector that usually results in this default value, but can be manipulated by Area2Ds with gravity overrides.