Thank you so much for the response.
First off, I was expecting for my character to just fall not being bothered by the platform due to its gravity just like in the real world.
For the platform, its node structure looks like this:
| Node2D [script]
| StaticBody2D
| StaticBody2D
and Node2D
's script just makes the cross platforms rotate:
extends Node2D
func _physics_process(delta: float) -> void:
rotate(delta)
For the player I used move_and_slide_with_snap
in _physics_process
for handling velocity movement and stuff. Sticking to the platform might be due to how Godot processes move_and_slide
. Debugging while sticking to the platform, the velocity resets to Vector2(0, 0)
when it is collided on the ceiling.
Right now I have a barely working work-around, except:
- The player doesn't fall when touching the floor.
- The player penetrates the ground when getting squashed.
- Force doesn't exist for the player, when getting shoved down by and object it acts like it's nothing.
Here's the code for now:
var new_velocity = move_and_slide_with_snap(velocity, snap, FLOOR_NORMAL)
if !is_on_ceiling():
velocity = new_velocity
else:
if velocity.y < 0:
velocity.y = 0
position.y += velocity.y*delta
