KinematicBody2D Arrow Shoot on KinematicBody2D Enemy cause the enemy to walk in inverse direction after collision

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

As the title mentioned, why is this happening? My codes are as below:

Arrow code:

func _physics_process(delta):
if velocity.y < max_shoot_down_speed:
	velocity.y += Global.GRAVITY * mass * delta
var collision = move_and_collide(velocity*delta)
if collision:
	_on_hitting_target(collision)
rotation = velocity.angle()

func _on_hitting_target(collision):
set_physics_process(false)
if collision.collider.is_in_group("Stickable"):
            velocity = Vector2.ZERO
	var target_node = collision.collider
	var temp_position = global_position
	var temp_rotation = global_rotation_degrees
	get_parent().remove_child(self)
	target_node.add_child(self)
	self.global_position = temp_position
	self.global_rotation_degrees = temp_rotation

My enemy moving code is as below:

velocity.y += Global.GRAVITY*delta
move_and_slide(velocity,Vector2(0,-1))

My expectation will be after collision, my enemy still moving constantly with his velocity, but move_and_slide() always return me a velocity that seems like affect by the arrow i attached to it.

Anyone please help.