Forráskód Böngészése

Slightly reduce contact correction

To prevent making contact appear on the other side of the brick
(over-correction).
DricomDragon 3 éve
szülő
commit
ef2ec35f49
1 módosított fájl, 3 hozzáadás és 1 törlés
  1. 3 1
      godot/scripts/Ball.gd

+ 3 - 1
godot/scripts/Ball.gd

@@ -10,6 +10,8 @@ signal kace_contact
 const brick_layer = 2
 const interrupt_speed = 700
 const cell_size = Vector2(20, 10)
+const max_penetration = 1.0
+const contact_corrector = cell_size - Vector2(max_penetration, max_penetration)
 const redundant_ceil = 0.9 # 0.5 < x < 1.0
 
 
@@ -38,7 +40,7 @@ func _integrate_forces(state :  Physics2DDirectBodyState):
 		var contact_normal = state.get_contact_local_normal(i)
 		if filter_new_contact(contact_normal):
 			var contact_pos = state.get_contact_local_position(i)
-			var correct_pos = contact_pos - contact_normal * cell_size
+			var correct_pos = contact_pos - contact_normal * contact_corrector
 			emit_signal("kace_contact", correct_pos)