CollisionShape2D Disabled, but still acting

Godot Version

4.3!

Question

Hello! Thanks for checking my problem!
I juiced up the death animation from immediately respawning in the last check point to having the classic falling off the screen like in Mario. But for some reason, the character’s collision box is still active despite the script turning it off as seen in the GIF. The animation player doesn’t affect collision, just has animations in rotation for “Death” and transform for “Idle”

godot.windows.opt.tools.64_J4tF1tcd4z

imagen

func player_death ():
	collision_shape_2d.disabled = true #Juice part 1
	velocity.y = -1500
	animation_player.play("Death")
	InUse = false
	audio_stream_player.play()
	
	retry_counter += 1 #Score system
	add_score(-1000)
	
	camera_shake() #Juice part 2
	frame_freeze(0.05, 1.5)
	await get_tree().create_timer(1.5).timeout # waits for 1 second
	
	collision_shape_2d.disabled = false #Respawn system
	animation_player.play("Idle")
	InUse = true
	global_position = respawn_position

imagen

func _on_area_2d_body_entered(body: Node2D) -> void:
	if body.is_in_group("PlayerCharacter"):
		body.player_death()

Any warnings? maybe use collision_shape_2d.set_deferred("disabled", true). Many collision properties do not like being updated during the physics frame.

1 Like

Seems to do the job, thank you very much!
v4