I created a vertically moving platform but it gets stuck when it's moving upwards and the player lands on it

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By i_am_dhrutiman1999

extends KinematicBody2D

var speed = Vector2()
var acc = Vector2()
var direction

func _ready() → void:
Global.platform = self
set_physics_process(true)
direction = 1

func _physics_process(delta: float) → void:

acc.y = 90
acc.x = 0
speed.x = acc.x * delta
speed.y = acc.y * direction * delta
move_and_collide(speed)

func _on_Timer_timeout() → void:
if (direction == 1):
direction = -1
else:
direction = 1

	
	
:bust_in_silhouette: Reply From: Dragon

instead of move_and_slide()
try using move_and_slide_with_snap()

Should I implement that in the Platform script or player … because I did that in the Player but it still doesn’t works

i_am_dhrutiman1999 | 2020-08-07 17:36

this video explains well try watching it and give me feedback https://www.youtube.com/watch?v=2ykdYUA40Ds

Dragon | 2020-08-07 17:40

The video’s good but still doesn’t solve my problem.

The platform still gets stuck but the player is moving alright… I’m really getting frustrated now so much that I’m on the verge of dropping this project…if possible do send me the code of a vertically moving platform

i_am_dhrutiman1999 | 2020-08-07 20:32

I understand your pain. Don’t drop down your project. I’ve been trying to do something I can’t find help for anywhere and I almost gave up. But I’m new to programming so I don’t know how to help you but I can give you tips. Try doing another platform the same way he did and make it so that it looks as big and moves as fast as your wanted preferences. You can try looking up videos for that as well. I’m sorry I can’t help much as I’m still learning most of the basics of godot

Dragon | 2020-08-07 20:40

Just an update…I’m using a platform with animation… although now the platform doesn’t get stuck but it still shakes when it goes up with the player on it

i_am_dhrutiman1999 | 2020-08-08 18:20