Restricted gravity flipping to only work when on a floor or ceiling.
This commit is contained in:
parent
21037cd792
commit
60e043e812
2 changed files with 5 additions and 3 deletions
File diff suppressed because one or more lines are too long
|
|
@ -1,7 +1,8 @@
|
||||||
extends CharacterBody2D
|
extends CharacterBody2D
|
||||||
|
|
||||||
@onready var tile_layer : TileMapLayer = $"../TileMap"
|
@onready var tile_layer : TileMapLayer = $"../TileMapLayer"
|
||||||
|
|
||||||
|
@export_category("Movement")
|
||||||
@export var acceleration : float = 50
|
@export var acceleration : float = 50
|
||||||
@export var braking : float = 20
|
@export var braking : float = 20
|
||||||
@export var move_speed : float = 100
|
@export var move_speed : float = 100
|
||||||
|
|
@ -19,7 +20,8 @@ func _physics_process(delta: float) -> void:
|
||||||
|
|
||||||
#Vertical movement.
|
#Vertical movement.
|
||||||
velocity.y += al_globals.gravity * delta
|
velocity.y += al_globals.gravity * delta
|
||||||
if Input.is_action_just_pressed("flip"):
|
|
||||||
|
if Input.is_action_just_pressed("flip") and (is_on_floor() or is_on_ceiling()):
|
||||||
al_globals.gravity *= -1
|
al_globals.gravity *= -1
|
||||||
|
|
||||||
move_and_slide() #Allow physics control.
|
move_and_slide() #Allow physics control.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue