Godot Version
4.2.2.stable.mono
Question
(Solved, thank you! )
Hello! I’m trying to make a Geometry Dash style game to just get some practice, but I’m having trouble with the flipping. It’s supposed to “land” on the side that is facing the ground, but it will just land upright. Any idea what the problem could be? Thanks! I will give more context if needed
Sprite2D (To give the effect of rotating):
extends Sprite2D
var rotEnd = 0
@onready var cube = $".." #cube is the parent node.
func _ready():
rotation = 0
func _process(delta):
if !cube.isOnFloor:
rotation += 8 * delta
else:
rotEnd = round(global_rotation/90) * 90
print(global_rotation)
print(rotEnd)
rotation = lerp_angle(global_rotation, rotEnd, 8 * delta)
CharacterBody2D (Parent, for actually jumping)
extends CharacterBody2D
@export var JUMP_VELOCITY = 1250
@export var gravity = 3500
var lerpRotation : float = 0.0
var isOnFloor : bool = false
# Get the gravity from the project settings to be synced with RigidBody nodes.
var settingGravity = ProjectSettings.get_setting("physics/2d/default_gravity")
func _physics_process(delta):
lerpRotation = rotation + 90.0
settingGravity = gravity
# Add the gravity.
if not is_on_floor():
velocity.y += settingGravity * delta
isOnFloor = false
else:
isOnFloor = true
if Input.is_action_pressed("ui_accept") and is_on_floor():
velocity.y = -JUMP_VELOCITY
move_and_slide()