Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | smetek |
I made a moving platform which is kinematicbody2d and when a player (which is a kinematicbody2d too) stands on it moving platform is going down. I don’t know why.
Moving platform script:
extends KinematicBody2D
var velocity = Vector2.ZERO
var x_direction = 1
var x_speed = 30
var y_speed = 1
var y_direction = 1
func _physics_process(delta):
#X
velocity.x = x_speed * x_direction
var collision = move_and_collide(velocity * delta)
if collision != null and collision.collider.is_in_group("Ground"):
if x_direction == 1:
x_direction = -1
elif x_direction == -1:
x_direction = 1
#Y
velocity.y = y_speed * y_direction
func _on_Timer_timeout():
y_direction = -1
func _on_Timer2_timeout():
y_direction = 1
did you make collision shape for the platform?
hero2002 | 2020-06-15 21:30
Yes i did make a collision shape.
smetek | 2020-06-15 21:41
i think you shouldnt make the platform with kinematicbody2d use instead staticbody2d or if you have tileset make tilemap
hero2002 | 2020-06-15 21:46