i cant be killed if on ground, standing still or moving.

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

i can stand on the enemy and run in to them. but if i jump while colliding, i die.
i tested this out on the enemy with same code and they do die if they touch me. so i dont understand what in my code that’s overwrite the code.

func _process(delta):
if is_dead == false:
	if Input.is_action_pressed("ui_right"):
			velocity.x = min(velocity.x+acceleration, max_run_speed)
			if is_attacking == false:
				$AnimatedSprite.flip_h = false
				if sign($Position2D.position.x) == -1:
					$Position2D.position.x *= -1
	elif Input.is_action_pressed("ui_left"):
			velocity.x = max(velocity.x-acceleration, -max_run_speed)
			if is_attacking == false:
				$AnimatedSprite.flip_h = true
				if sign($Position2D.position.x) == 1:
					$Position2D.position.x *= -1
		velocity.x = 0 
		if on_ground == true && is_attacking == false:
	if Input.is_action_just_pressed("ui_up"):
		#if on_ground == true:
			#velocity.y = jump_speed
			#on_ground = false
			if jump_count < 2:
				jump_count += 1
				velocity.y = jump_speed
				on_ground = false
	if Input.is_action_just_pressed("ui_focus_next") && is_attacking == false:
		is_attacking = true
		var fireball = FIREBALL.instance()
		if sign($Position2D.position.x) == 1:
		fireball.position = $Position2D.global_position

velocity.y += gravity * delta

velocity = move_and_slide(velocity, Floor)
if is_on_floor():
	on_ground = true
	jump_count = 0
	if is_attacking == false:
		on_ground = false
		if velocity.y >0:
		elif velocity.y <0:
		if get_slide_count() > -1:
			for i in range(get_slide_count()):
				if "enemy" in get_slide_collision(i).collider.name:

Your collision check is under an else statement, so you only check for collisions if the player is not on floor.

Adam_S | 2019-09-07 10:53