Set center of gravity correctly when shrinking Nodes Control

This commit is contained in:
Sebastian Morr 2020-09-24 10:31:41 +02:00
parent 47f412d3d8
commit a083e6a1da
3 changed files with 7 additions and 6 deletions

View file

@ -15,7 +15,7 @@ func _process(_delta):
position = Vector2(0,0)
var start = repository.objects[source].position
var end = start + Vector2(0, 30)
var end = start + Vector2(0, 60)
if repository and repository.objects.has(target) and repository.objects[target].visible:
var t = repository.objects[target]

View file

@ -47,10 +47,10 @@ __meta__ = {
}
[node name="Target" type="Label" parent="."]
margin_left = -229.024
margin_top = 63.3118
margin_right = 232.976
margin_bottom = 89.3118
margin_left = -230.84
margin_top = 42.1225
margin_right = 231.16
margin_bottom = 68.1225
custom_fonts/font = ExtResource( 2 )
custom_colors/font_color = Color( 0.356863, 0.356863, 0.356863, 1 )
text = "label"

View file

@ -142,7 +142,8 @@ func apply_forces():
var f = 2000/pow(d+0.00001,1.5)
o.position += dir*f
o2.position -= dir*f
var center_of_gravity = rect_size/2
var center_of_gravity = nodes.rect_size/2
print(center_of_gravity)
var d = o.position.distance_to(center_of_gravity)
var dir = (o.position - center_of_gravity).normalized()
var f = (d+0.00001)*Vector2(0.03, 0.01)