Godot version:
3.1.1.stable.official
OS/device including version:
Windows 10 and Android (OnePlus 6T)
Issue description:
I created vertically moving platforms with RigidBody2D and a RigidBody2D player.
With CapsuleShape2D Player falls through the Vertically (didn't notice this issue with Horizontally moving platforms) moving platforms when the platform moves up, but the player falls down (at least it visually seems so). With RectangleShape2D it seems to work better, I haven't encountered this problem with that shape yet. Here are some example GIFs:
CapsuleShape2D:

RectangleShape2D:

Steps to reproduce:
With player jump on a vertically moving platform at an interval (not constantly, let the player land on platform).
Minimal reproduction project:
The platforms are One Way Collision enabled and move using a tween (I basically followed a YT tutorial on moving platforms, and modified a code a little to meet my needs), here's relevant code and screens (everything else is default) the move_to is a Position2D node I use in Level chunks:
const IDLE_DURATION = 0.5
export (NodePath) var move_to = null
export (float) var speed = 300.0
onready var tween = $MoveTween
func _ready():
_init_tween()
func _init_tween():
if move_to != null:
move_to = get_node(move_to).position
var duration = move_to.length() / speed
tween.interpolate_property(self, "position", position, position + move_to, duration, Tween.TRANS_LINEAR, Tween.EASE_OUT_IN, IDLE_DURATION)
tween.interpolate_property(self, "position", position + move_to, position, duration, Tween.TRANS_LINEAR, Tween.EASE_OUT_IN, duration + IDLE_DURATION * 2)
tween.start()
Player is a KinematicBody2D with CapsuleShape2D with a standard movement code (except it's controlled with virtual joystick, which shouldn't really be an issue.. the analog_position.x value is float from -1.0 to 1.0 and is_analog_pressed is a boolean), here's the relevant code and node-tree (everything else is default):
func _physics_process(delta):
velocity.x = speed * analog_position.x
var snap = Vector2.DOWN * 32
if is_on_floor() && is_analog_pressed:
snap = Vector2.ZERO
velocity.y = jump_str
velocity.y += gravity * delta
velocity = move_and_slide_with_snap(velocity, snap, Vector2.UP)
if position.x < 0:
position.x = 720
elif position.x > 720:
position.x = 0
ZIP archive of the minimal project:
issue_28794.zip
For the minimal project, you can attach a zip of it on your post.
For the minimal project, you can attach a zip of it on your post.
Oh, right! Will create one and post it here later today.
I have encountered this exact problem with my player and moving platforms, which are KinematicBody2Ds. It looks exactly like your footage.
Periodically when my player lands on platforms that are moving upwards, he lands briefly before falling through the platform on the next frame.
The player is a Kinematic2D with a capusle shape and the platform is a KinematicBody2D with a rectangle shape. The moving platform has one_way_collision = true and one_way_collision_margin = 1. The platform is moved with a Tween. The platform has sync_to_physics = true and the tween has playback_process_mode set to physics. The player is moved with move_and_slide_with_snap().
I think what happens is that the player lands on the platform and in the same frame the platform is moved a few pixels up, which puts the bottom of the player below the top of the platform causing the player to fall.
It only happens periodically when jumping onto upwards-moving platforms, and can even happen when the player has very low y-velocity.
I though syncing everything to physics would avoid this, but it still happens periodically when using a capsule shape.
I would really love a fix because I don't want to use a rectangle over a capsule. Further, I don't want to increase the platform's one_way_collision_margin, which does help mitigate the problem, since I don't want that kind of snapping in my game.
I can confirm this is broken in 3.2.3.stable and #42574 fixed it for me on the 3.2 branch.
Most helpful comment
I can confirm this is broken in 3.2.3.stable and #42574 fixed it for me on the 3.2 branch.