diff --git a/Autoload/Utilities.gd b/Autoload/Utilities.gd index 8cc0af4..ce2968d 100644 --- a/Autoload/Utilities.gd +++ b/Autoload/Utilities.gd @@ -6,5 +6,6 @@ extends Node const LOOK_AT_OFFSET_FIX = Vector3(0.01, 1, 0.01) -func uniform_vector3(value : float): +# Compose an uniform Vector3 from a float value +func uniform_vec3(value : float): return Vector3(value, value, value) diff --git a/Ball/ball.gd b/Ball/ball.gd index f55965d..be1ee0a 100644 --- a/Ball/ball.gd +++ b/Ball/ball.gd @@ -20,7 +20,6 @@ func _physics_process(delta): _get_collision(delta) - ### DEBUG # Delete balls that escape the level if global_position.length() > 20.0: @@ -78,6 +77,7 @@ func _after_collision(): freeze = false linear_velocity = bounced_velocity + ### DEBUG - freeze = true +# freeze = true # queue_free() diff --git a/Ball/ball.tscn b/Ball/ball.tscn index 1fd79a2..432f571 100644 --- a/Ball/ball.tscn +++ b/Ball/ball.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://rdlvlyf0l1l"] +[gd_scene load_steps=7 format=3 uid="uid://rdlvlyf0l1l"] [ext_resource type="Script" path="res://Ball/ball.gd" id="1_oenn5"] [ext_resource type="PackedScene" uid="uid://lge7m41oi6pn" path="res://Ball/Meshes/ball_bouncing.glb" id="2_ccq7m"] @@ -9,9 +9,6 @@ [sub_resource type="SphereShape3D" id="SphereShape3D_ogc07"] radius = 0.3 -[sub_resource type="BoxMesh" id="BoxMesh_yno20"] -size = Vector3(0.2, 0.2, 0.2) - [node name="Ball" type="RigidBody3D" groups=["Balls"]] collision_layer = 4 custom_integrator = true @@ -45,7 +42,3 @@ script = ExtResource("5_j25qm") [node name="VectorPosition" type="Node3D" parent="RandomVectorNode"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1) - -[node name="debugmesh" type="MeshInstance3D" parent="RandomVectorNode/VectorPosition"] -mesh = SubResource("BoxMesh_yno20") -skeleton = NodePath("../../..") diff --git a/Ball/ball_random_vector_node.gd b/Ball/ball_random_vector_node.gd index 069fcf6..64cc8a5 100644 --- a/Ball/ball_random_vector_node.gd +++ b/Ball/ball_random_vector_node.gd @@ -2,6 +2,8 @@ extends Node3D @onready var ball = owner +var random_offset : Vector3 + func _ready(): ball.ball_collision_started.connect(_get_random_offset) @@ -18,3 +20,4 @@ func _get_random_offset(): var random_vector = Vector3(x, y, z) $VectorPosition.position += random_vector + random_offset = $VectorPosition.position