Hi all,
I've been following this tutorial: http://kidscancode.org/godot_recipes/physics/kinematic_to_rigidbody/
and I am stuck on how to move crates(rigidbody2d) with my player(kinematic2d). I have put the infinite_intertia for move_and_slide() to false and now whenever the player bumps into the crates it nothing happens (as video shown). However when I try it, the collisions dont seem to work. Does anyone have any ideas?
Below is my code:
func _physics_process(delta):
# Player input
get_input()
# Player movement
velocity.y += gravity * delta
velocity = move_and_slide(velocity, Vector2.UP,
false, 4, PI/4, false) # changes players inertia
if Input.is_action_just_pressed("ui_up"):
if is_on_floor():
velocity.y = jump_speed
# Player collisions with crates
for index in get_slide_count():
print(index)
var collision = get_slide_collision(index)
if collision.collider.is_in_group("bodies"):
collision.collider.apply_central_impulse(-collision.normal * push)