Apply_central_impulse is not working properly with rigidbody3D

Godot Version



I’m trying to make my player throw a card when a button on the controller/keyboard is pressed. To achieve this, I am dynamically instantiating a Rigidbody3D card at the player’s Raycast3D position and applying an impulse to make the card fall to the ground when thrown. However, it’s not working properly, the card is floating in the air, and the player is being pushed backward for no reason:

Here is my code, i don’t know what’s wrong with it:
Player class:

func throw_card(card_id: int):
	var instance: Object = preload("res://scenes/env/card_physic_item.tscn")
	var instance_card: CardPhysicItem = instance.instantiate() #instantiate the scene of the card dynamically
	instance_card.position = ray_cast_3d.global_position #set the position and basis of where raycast is pointing
	instance_card.transform.basis = ray_cast_3d.global_transform.basis
	instance_card.update_card(card_id) #update the id of the card
	get_parent().add_child(instance_card) #add it to the scene

Card class:

func update_card(id_card: int):
	await self.ready #wait until the card is not ready
	item_sprite.frame = id_card #change the sprite based on id of the card
	apply_card_impulse() #apply the impulse to rigidbody which is the card in this case

func apply_card_impulse()->void:"throw_card") # Play an animation
	apply_central_impulse(Vector3(0, 0, -1000)) # Apply a central impulse to the rigidbody
	print("applied card impulse")

Could someone help me figure out how to solve this? Or does anyone know another approach that yields the same result? Thank you very much

I FOUND IT! The problem wasn’t in my code, it was in my animation. I changed the rotation of the entire Rigidbody in the animation player instead of just the sprite itself. That’s why it was so buggy, and sometimes the card gets stuck in mid-air for no reason hahaha.