Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | David Wong |
I’m making a menu level swipe, but there is a problem when shifting the card, the card seems to vibrate. is there something wrong with the code i made ?,
But when the card is set pivot_offset to a value of 0, the card becomes normal.
Thank you for your help
extends ScrollContainer
onready var margin_container: MarginContainer = $CenterContainer/MarginContainer
onready var card_node_list: Array = $CenterContainer/MarginContainer/HBoxContainer.get_children()
func _process(delta: float) -> void:
var _center_pos: Vector2 = (rect_size / 2)
for _card in card_node_list:
var _card_pos = _card.rect_global_position.x
if _card_pos > (_center_pos.x - 100) and _card_pos < (_center_pos.x + 100):
_card.rect_scale = lerp(_card.rect_scale, Vector2(1, 1), 0.1)
else:
_card.rect_scale = lerp(_card.rect_scale, Vector2(0.7, 0.7), 0.1)