Delay in Mouse Enter/Exit Functions in one direction?

Godot Version

4.2.2

Question

I’m making a card game where I have a hand of cards at the bottom of the screen (like Balatro, Slay the Spire, etc.). When you mouse over a card it gets bigger and displays in front of the other cards (I reorder the children of the hand node so that the selected card is on top). Then when the mouse exits the card it pops back down the cards are reordered. I’m doing this with Controls using the mouse_entered/mouse_exited signals.

When the mouse moves too quickly, it doesn’t register the mouse exiting the card or entering another which makes sense as it would only be checking that at a fixed rate. BUT, this only happens when the mouse moves left not when it moves right:

Code Below:
select_card is connected to the mouse_entered signal and reset card to the mouse_exited signal

func select_card():
	z_index += 1
	get_parent().move_child(self, -1)
	if tween_hover and tween_hover.is_running():
		tween_hover.kill()
	tween_hover = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_ELASTIC)
	tween_hover.tween_property(self, "scale", Vector2(1.5, 1.5), 0.5)
	
	
func reset_card():
	z_index = 0
	if get_parent() is Hand:
		reorder_cards()
	# Reset rotation
	if !get_tree():
		return
	if tween_rot and tween_rot.is_running():
		tween_rot.kill()
	tween_rot = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_BACK).set_parallel(true)
	tween_rot.tween_property(card_viewport_texture.material, "shader_parameter/x_rot", 0.0, 0.5)
	tween_rot.tween_property(card_viewport_texture.material, "shader_parameter/y_rot", 0.0, 0.5)
	
	# Reset scale
	if tween_hover and tween_hover.is_running():
		tween_hover.kill()
	tween_hover = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_ELASTIC)
	tween_hover.tween_property(self, "scale", Vector2.ONE, 0.55)


func reorder_cards():
	var cards = get_parent().get_children()
	cards.sort_custom(
		func(a,b) : return a.position.x > b.position.x
	)
	for card in cards:
		get_parent().move_child(card, 0)

Any ideas would be appreciated!

In the video it looks like the area of the cards extend too far to the right, so that mouse_exited gets triggered, when you move the mouse 3 or 4 cards to the right.
I haven’t used the entered/exited signals with tweens and can’t say, if that is the cause of the problem, but this looks like good material for a bug report.
Can you please open a bug report for this problem here:

1 Like

Okay yeah will do thank you!
I don’t think I showed this in the video properly but if you move the mouse slow enough it behaves like it should. It only gets stuck when you go quickly, so maybe something to do with the update order?

I figured it out I had a hidden UI element on the right hand side of the card that was taking the input. My bad, thanks for your help!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.