added debug stuff
This commit is contained in:
parent
22f17fdbff
commit
af1bdeb3ca
|
@ -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
|
|
@ -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")
|
11
Ball/ball.gd
11
Ball/ball.gd
|
@ -9,6 +9,7 @@ var bounced_velocity : Vector3
|
||||||
var just_collided = false
|
var just_collided = false
|
||||||
|
|
||||||
var total_bounce_duration = 0.5
|
var total_bounce_duration = 0.5
|
||||||
|
var bounce_factor_cap = 0.25
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
|
@ -19,6 +20,14 @@ func _physics_process(delta):
|
||||||
_get_collision(delta)
|
_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
|
var collision_normal : Vector3
|
||||||
var collision_angle_factor : float
|
var collision_angle_factor : float
|
||||||
func _get_collision(delta):
|
func _get_collision(delta):
|
||||||
|
@ -35,7 +44,7 @@ func _get_collision(delta):
|
||||||
collision_angle_factor = collision_normal.dot(captured_velocity.normalized() * -1)
|
collision_angle_factor = collision_normal.dot(captured_velocity.normalized() * -1)
|
||||||
|
|
||||||
# Cap the factor for collision angles that are too shallow
|
# 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
|
collision_angle_factor = 0
|
||||||
|
|
||||||
# Bounce back immediately if factor is 0
|
# Bounce back immediately if factor is 0
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_ogc07"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_ogc07"]
|
||||||
radius = 0.3
|
radius = 0.3
|
||||||
|
|
||||||
[node name="Ball" type="RigidBody3D"]
|
[node name="Ball" type="RigidBody3D" groups=["Balls"]]
|
||||||
collision_layer = 4
|
collision_layer = 4
|
||||||
custom_integrator = true
|
custom_integrator = true
|
||||||
max_contacts_reported = 1
|
max_contacts_reported = 1
|
||||||
|
|
|
@ -15,6 +15,10 @@ run/main_scene="res://World/world.tscn"
|
||||||
config/features=PackedStringArray("4.1", "Forward Plus")
|
config/features=PackedStringArray("4.1", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
Debug="*res://Autoload/Debug.tscn"
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
move_left={
|
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)
|
, 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]
|
[layer_names]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue