Fixed flicker
This commit is contained in:
@@ -32,6 +32,7 @@ func setup(responses:Array[DialogueResponse], entity:Entity) -> void:
|
||||
_list.add_child(label)
|
||||
|
||||
size.x = MAX_WIDTH
|
||||
modulate.a = 0.0
|
||||
visible = true
|
||||
_updateSelection()
|
||||
|
||||
@@ -79,9 +80,18 @@ func _updateWorldPosition() -> void:
|
||||
var camera:Camera3D = get_viewport().get_camera_3d()
|
||||
if camera == null:
|
||||
return
|
||||
if size.y == 0:
|
||||
return
|
||||
var worldPos:Vector3 = _entity.global_position + Vector3(0, 2.5, 0)
|
||||
if camera.is_position_behind(worldPos):
|
||||
modulate.a = 0.0
|
||||
return
|
||||
modulate.a = 1.0
|
||||
var screenPos:Vector2 = camera.unproject_position(worldPos)
|
||||
var viewportSize:Vector2 = get_viewport().get_visible_rect().size
|
||||
position = screenPos - Vector2(size.x * 0.5, size.y)
|
||||
position.x = clamp(position.x, 0.0, viewportSize.x - size.x)
|
||||
position.y = clamp(position.y, 0.0, viewportSize.y - size.y)
|
||||
position.x = clamp(screenPos.x - size.x * 0.5, 0.0, viewportSize.x - size.x)
|
||||
var yAbove:float = screenPos.y - size.y
|
||||
if yAbove >= 0.0:
|
||||
position.y = yAbove
|
||||
else:
|
||||
position.y = clamp(screenPos.y + 10.0, 0.0, viewportSize.y - size.y)
|
||||
|
||||
Reference in New Issue
Block a user