added debug stuff

This commit is contained in:
AmyLillya 2023-09-04 17:50:43 -03:00
parent 22f17fdbff
commit af1bdeb3ca
5 changed files with 37 additions and 2 deletions

11
Autoload/Debug.gd Normal file
View File

@ -0,0 +1,11 @@
extends Node
func _process(delta):
if Input.is_action_just_pressed("debug_1"):
print("total balls: ", get_total_ball_count())
func get_total_ball_count():
var total_balls : int = get_tree().get_nodes_in_group("Balls").size()
return total_balls

6
Autoload/Debug.tscn Normal file
View File

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://cpey4r5s1qsy8"]
[ext_resource type="Script" path="res://Autoload/Debug.gd" id="1_imoie"]
[node name="Debug" type="Node"]
script = ExtResource("1_imoie")

View File

@ -9,6 +9,7 @@ var bounced_velocity : Vector3
var just_collided = false
var total_bounce_duration = 0.5
var bounce_factor_cap = 0.25
func _physics_process(delta):
@ -17,6 +18,14 @@ func _physics_process(delta):
captured_velocity = linear_velocity
_get_collision(delta)
### DEBUG
# Delete balls that escape the level
if global_position.length() > 20.0:
print("ball deleted, total: ", Debug.get_total_ball_count())
queue_free()
var collision_normal : Vector3
@ -35,7 +44,7 @@ func _get_collision(delta):
collision_angle_factor = collision_normal.dot(captured_velocity.normalized() * -1)
# Cap the factor for collision angles that are too shallow
if collision_angle_factor < 0.25:
if collision_angle_factor < bounce_factor_cap:
collision_angle_factor = 0
# Bounce back immediately if factor is 0

View File

@ -8,7 +8,7 @@
[sub_resource type="SphereShape3D" id="SphereShape3D_ogc07"]
radius = 0.3
[node name="Ball" type="RigidBody3D"]
[node name="Ball" type="RigidBody3D" groups=["Balls"]]
collision_layer = 4
custom_integrator = true
max_contacts_reported = 1

View File

@ -15,6 +15,10 @@ run/main_scene="res://World/world.tscn"
config/features=PackedStringArray("4.1", "Forward Plus")
config/icon="res://icon.svg"
[autoload]
Debug="*res://Autoload/Debug.tscn"
[input]
move_left={
@ -48,6 +52,11 @@ shoot={
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"echo":false,"script":null)
]
}
debug_1={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":49,"key_label":0,"unicode":49,"echo":false,"script":null)
]
}
[layer_names]