recreate billard table and add ball movement

main
DJh2o2 2025-03-27 10:36:15 +07:00
parent 818f1445b1
commit 9f30549790
6 changed files with 1003 additions and 17 deletions

@ -0,0 +1,19 @@
[gd_scene load_steps=4 format=3 uid="uid://r1vdoioeyb53"]
[ext_resource type="ArrayMesh" uid="uid://bk3hh360blgwq" path="res://assets/ball.res" id="1_7s4qf"]
[ext_resource type="Script" uid="uid://cq2m3ftgtcof5" path="res://scripts/ball.gd" id="1_cxlvu"]
[sub_resource type="SphereShape3D" id="SphereShape3D_7s4qf"]
radius = 0.027
[node name="Ball" type="RigidBody3D"]
script = ExtResource("1_cxlvu")
[node name="Mesh" type="MeshInstance3D" parent="."]
mesh = ExtResource("1_7s4qf")
[node name="CollisionShape" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_7s4qf")
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]

@ -75,3 +75,5 @@ visible = false
[node name="Cue 1" parent="." index="23"]
visible = false
[node name="Node3D" type="Node3D" parent="." index="24"]

File diff suppressed because one or more lines are too long

@ -1,7 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://232jf7nn8nmo"]
[ext_resource type="PackedScene" uid="uid://bjgntfhmyaf67" path="res://scenes/billiard_table.tscn" id="1_ig7tw"]
[ext_resource type="ArrayMesh" uid="uid://bk3hh360blgwq" path="res://assets/ball.res" id="2_0wfyh"]
[ext_resource type="PackedScene" uid="uid://bilcpil4nmtb3" path="res://scenes/billiard_table_new.tscn" id="1_0wfyh"]
[ext_resource type="PackedScene" uid="uid://r1vdoioeyb53" path="res://scenes/ball.tscn" id="2_0wfyh"]
[sub_resource type="Environment" id="Environment_sugp2"]
tonemap_mode = 3
@ -17,33 +17,26 @@ transform = Transform3D(1, 0, 0, 0, 0.536725, 0.843757, 0, -0.843757, 0.536725,
environment = SubResource("Environment_sugp2")
[node name="Sun" type="DirectionalLight3D" parent="Camera3D"]
transform = Transform3D(-0.586372, -0.347455, 0.731739, 0.404568, 0.656985, 0.636156, -0.701778, 0.669062, -0.244669, 0.524668, 1.11203, 0.249249)
transform = Transform3D(-0.586372, -0.347455, 0.731739, 0.404568, 0.656986, 0.636156, -0.701778, 0.669063, -0.244669, 0.524668, 2.11785, 1.83045)
light_color = Color(1, 0.866667, 0.643137, 1)
light_energy = 0.5
shadow_enabled = true
[node name="Billiard Table" parent="." instance=ExtResource("1_ig7tw")]
shadow_bias = 0.05
[node name="Light1" type="SpotLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.75, 0.595, 0)
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.75, 1.03075, 0)
shadow_enabled = true
shadow_bias = 0.05
spot_angle = 55.0
[node name="Light2" type="SpotLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.75, 0.595, 0)
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0.75, 1.03075, 0)
shadow_enabled = true
shadow_bias = 0.05
spot_angle = 55.0
[node name="Ball" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.787929, 0.136649, 0.029739)
mesh = ExtResource("2_0wfyh")
[node name="Ball2" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.362567, 0.0940399, 0.029739)
mesh = ExtResource("2_0wfyh")
[node name="BillardTable" parent="." instance=ExtResource("1_0wfyh")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.812356, -0.298113, 0)
[node name="Ball3" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.175626, 0.0940399, -0.225789)
mesh = ExtResource("2_0wfyh")
[node name="Ball" parent="." instance=ExtResource("2_0wfyh")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.755, 1.5, -0.057)

@ -0,0 +1,10 @@
extends RigidBody3D
var speed: float = 0.1
func _on_mouse_entered() -> void:
var impulse: Vector3 = Vector3(randf() * speed, 0, randf() * speed)
apply_impulse(impulse)
func _on_mouse_exited() -> void:
pass # Replace with function body.

@ -0,0 +1 @@
uid://cq2m3ftgtcof5