From 57cbd00dc21ace47b3615030e66f2259fbcbb96a Mon Sep 17 00:00:00 2001 From: nebunez Date: Mon, 3 Jan 2022 19:37:53 -0500 Subject: [PATCH] add collision test --- Game/Ball.gd | 7 +++++ Game/CollisionTest.tscn | 57 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 Game/Ball.gd create mode 100644 Game/CollisionTest.tscn diff --git a/Game/Ball.gd b/Game/Ball.gd new file mode 100644 index 0000000..2d19e26 --- /dev/null +++ b/Game/Ball.gd @@ -0,0 +1,7 @@ +extends Area3D + +func _physics_process(_delta): + translate_object_local(Vector3.FORWARD * -0.005) + +func _on_Area3D_body_entered(_body): + queue_free() diff --git a/Game/CollisionTest.tscn b/Game/CollisionTest.tscn new file mode 100644 index 0000000..3b08b59 --- /dev/null +++ b/Game/CollisionTest.tscn @@ -0,0 +1,57 @@ +[gd_scene load_steps=9 format=3 uid="uid://ccxgg2sh56ey3"] + +[ext_resource type="Script" path="res://Ball.gd" id="2_niom1"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_7sl5u"] +size = Vector3(1, 1, 1) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_x65hh"] +albedo_color = Color(0.527172, 0.355765, 1, 1) + +[sub_resource type="BoxMesh" id="BoxMesh_tlnxn"] +size = Vector3(1, 1, 1) + +[sub_resource type="SphereShape3D" id="SphereShape3D_o2k46"] + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_8vffl"] +albedo_color = Color(0.0392157, 1, 0.803922, 1) + +[sub_resource type="SphereMesh" id="SphereMesh_fthhh"] + +[sub_resource type="Environment" id="Environment_j8uk3"] +background_energy = 0.5 + +[node name="CollisionTest" type="Node3D"] + +[node name="StaticBody3D" type="StaticBody3D" parent="."] +transform = Transform3D(5, 0, 0, 0, 5, 0, 0, 0, 1, 0, 0, 0) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] +shape = SubResource( "BoxShape3D_7sl5u" ) + +[node name="MeshInstance3D" type="MeshInstance3D" parent="StaticBody3D"] +material_override = SubResource( "StandardMaterial3D_x65hh" ) +mesh = SubResource( "BoxMesh_tlnxn" ) + +[node name="Area3D" type="Area3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -3) +script = ExtResource( "2_niom1" ) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"] +shape = SubResource( "SphereShape3D_o2k46" ) + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Area3D"] +material_override = SubResource( "StandardMaterial3D_8vffl" ) +mesh = SubResource( "SphereMesh_fthhh" ) + +[node name="Camera3D" type="Camera3D" parent="."] +transform = Transform3D(-0.0810216, -0.439241, 0.894708, 0, 0.897659, 0.44069, -0.996712, 0.0357054, -0.0727297, 6.14121, 2.79573, -0.759574) +environment = SubResource( "Environment_j8uk3" ) +current = true + +[node name="OmniLight3D" type="OmniLight3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 4, -5) +light_color = Color(0, 1, 0.992157, 1) +omni_range = 50.0 + +[connection signal="body_entered" from="Area3D" to="Area3D" method="_on_Area3D_body_entered"]