chore: restructured project
All checks were successful
Coding Quality / Build and analyze (pull_request) Successful in 2m10s
All checks were successful
Coding Quality / Build and analyze (pull_request) Successful in 2m10s
This commit is contained in:
49
Experiments/SpaceMove/Assets/player_ship.tscn
Normal file
49
Experiments/SpaceMove/Assets/player_ship.tscn
Normal file
@@ -0,0 +1,49 @@
|
||||
[gd_scene format=3 uid="uid://c8tm1q2cp567o"]
|
||||
|
||||
[ext_resource type="Script" path="res://Experiments/SpaceMove/Scripts/player_ship.gd" id="1_3yydb"]
|
||||
[ext_resource type="Script" path="res://Experiments/SpaceMove/Scripts/shipAiComponent.gd" id="2_vr0dq"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_tjnu1"]
|
||||
radius = 1.48237
|
||||
height = 3.89605
|
||||
|
||||
[sub_resource type="PrismMesh" id="PrismMesh_tjnu1"]
|
||||
|
||||
[sub_resource type="CylinderMesh" id="CylinderMesh_3yydb"]
|
||||
|
||||
[node name="PlayerShip" type="RigidBody3D"]
|
||||
script = ExtResource("1_3yydb")
|
||||
_start_direction = Vector3(0, 0, -50)
|
||||
_start_speed = 1.0
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, -0.358494)
|
||||
shape = SubResource("CapsuleShape3D_tjnu1")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="CollisionShape3D"]
|
||||
transform = Transform3D(2.20781, 0, 0, 0, -9.18077e-08, -1.7005, 0, 2.10032, -7.43314e-08, 0, 0.524807, 0.378866)
|
||||
mesh = SubResource("PrismMesh_tjnu1")
|
||||
skeleton = NodePath("../..")
|
||||
|
||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="CollisionShape3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.475193, -2.07714e-08)
|
||||
mesh = SubResource("CylinderMesh_3yydb")
|
||||
skeleton = NodePath("../..")
|
||||
|
||||
[node name="ShipAiComponent" type="Node" parent="."]
|
||||
script = ExtResource("2_vr0dq")
|
||||
metadata/_custom_type_script = "uid://ci33hs6nbuhqr"
|
||||
|
||||
[node name="Label3D" type="Label3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.32815, 0)
|
||||
billboard = 2
|
||||
no_depth_test = true
|
||||
render_priority = 1
|
||||
text = "Text"
|
||||
font_size = 128
|
||||
|
||||
[node name="RayCast3D" type="RayCast3D" parent="."]
|
||||
target_position = Vector3(0, 0, 0)
|
||||
hit_from_inside = true
|
||||
collide_with_areas = true
|
||||
debug_shape_custom_color = Color(0.712962, 0.712962, 0.712962, 1)
|
||||
71
Experiments/SpaceMove/Scenes/space_test.tscn
Normal file
71
Experiments/SpaceMove/Scenes/space_test.tscn
Normal file
@@ -0,0 +1,71 @@
|
||||
[gd_scene format=3 uid="uid://dgst4apmowe53"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cc7e4loxpb1x6" path="res://Experiments/ThrusterCube/Scenes/obstacle.tscn" id="1_ig7tw"]
|
||||
[ext_resource type="PackedScene" uid="uid://c8tm1q2cp567o" path="res://Experiments/SpaceMove/Assets/player_ship.tscn" id="2_0xm2m"]
|
||||
[ext_resource type="PackedScene" uid="uid://1al1ysn5q5yk" path="res://Experiments/ThrusterCube/Scenes/thruster_cube.tscn" id="3_h2yge"]
|
||||
[ext_resource type="Script" path="res://Experiments/SpaceMove/Scripts/player_ship.gd" id="4_10w3i"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_hsoxx"]
|
||||
|
||||
[sub_resource type="Sky" id="Sky_gojnm"]
|
||||
sky_material = SubResource("ProceduralSkyMaterial_hsoxx")
|
||||
process_mode = 1
|
||||
|
||||
[sub_resource type="Environment" id="Environment_hsoxx"]
|
||||
background_mode = 2
|
||||
sky = SubResource("Sky_gojnm")
|
||||
ambient_light_source = 3
|
||||
ambient_light_color = Color(1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_1c2mv"]
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_0xm2m"]
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_h2yge"]
|
||||
|
||||
[node name="TestLevel" type="Node3D" unique_id=652844344]
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="." unique_id=150721961]
|
||||
transform = Transform3D(0.998445, -0.0179374, 0.0527875, -9.30799e-10, 0.946829, 0.321737, -0.0557519, -0.321236, 0.945357, 0.181835, 5.6324, 24.1051)
|
||||
fov = 50.4
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=972963566]
|
||||
environment = SubResource("Environment_hsoxx")
|
||||
camera_attributes = SubResource("CameraAttributesPractical_1c2mv")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=419392911]
|
||||
transform = Transform3D(0.933305, -0.340159, 0.115038, 0, 0.320365, 0.947294, -0.359085, -0.884114, 0.298998, 0, 1.65681, 0)
|
||||
|
||||
[node name="Node" type="Node3D" parent="." unique_id=1060338205]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.112919, -16.6481, 0.0137749)
|
||||
|
||||
[node name="Obstacle" parent="Node" unique_id=1151336365 instance=ExtResource("1_ig7tw")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.528058, 1.09307, -4.11262)
|
||||
|
||||
[node name="PlayerShip" parent="Node" unique_id=1169721436 instance=ExtResource("2_0xm2m")]
|
||||
transform = Transform3D(-0.0337657, 0, -0.99943, 0, 1, 0, 0.99943, 0, -0.0337657, -20.7388, 9.76772, -1.42542)
|
||||
_start_direction = Vector3(1, 0.5, 0)
|
||||
_start_speed = 100.0
|
||||
|
||||
[node name="Marker3D" type="Marker3D" parent="Node" unique_id=1294508738]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.147182, -10.5201)
|
||||
gizmo_extents = 5.03
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Node/Marker3D" unique_id=545308513]
|
||||
transform = Transform3D(0.189904, 0, 0, 0, 0.189904, 0, 0, 0, 0.189904, 0, 0, 0)
|
||||
mesh = SubResource("SphereMesh_0xm2m")
|
||||
|
||||
[node name="Obstacle2" parent="Node" unique_id=579337740 instance=ExtResource("1_ig7tw")]
|
||||
transform = Transform3D(0.635485, -0.772113, 0, 0.772113, 0.635485, 0, 0, 0, 1, -6.93043, 24.3938, -1.34355)
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Node" unique_id=257615271]
|
||||
transform = Transform3D(11.7541, 0, 0, 0, 1, 0, 0, 0, 11.7541, 0, -7, 0)
|
||||
mesh = SubResource("PlaneMesh_h2yge")
|
||||
skeleton = NodePath("../..")
|
||||
|
||||
[node name="Thruster Cube" parent="." unique_id=580986924 instance=ExtResource("3_h2yge")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -11.2033)
|
||||
mass = 200.0
|
||||
script = ExtResource("4_10w3i")
|
||||
_start_direction = Vector3(0, 0, 0)
|
||||
_start_speed = 0.0
|
||||
8
Experiments/SpaceMove/Scripts/player_ship.gd
Normal file
8
Experiments/SpaceMove/Scripts/player_ship.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
extends RigidBody3D
|
||||
|
||||
@export var _start_direction: Vector3
|
||||
@export var _start_speed: float
|
||||
|
||||
func _ready():
|
||||
# apply_force(_, global_position)
|
||||
apply_central_force(_start_direction.normalized() * _start_speed)
|
||||
1
Experiments/SpaceMove/Scripts/player_ship.gd.uid
Normal file
1
Experiments/SpaceMove/Scripts/player_ship.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ccnbhjxglgw12
|
||||
40
Experiments/SpaceMove/Scripts/shipAiComponent.gd
Normal file
40
Experiments/SpaceMove/Scripts/shipAiComponent.gd
Normal file
@@ -0,0 +1,40 @@
|
||||
extends Node
|
||||
class_name ShipAiComponent
|
||||
|
||||
var text: Label3D
|
||||
var colShape: CollisionShape3D
|
||||
var distText = "Distance to collision: "
|
||||
var secText = "Seconds to collision: "
|
||||
|
||||
var dist = 0.0
|
||||
var collision = 0.0
|
||||
|
||||
func _ready():
|
||||
text = $"../Label3D"
|
||||
colShape = $"../CollisionShape3D"
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
calcColDist(delta)
|
||||
|
||||
text.text = distText + String("%0.2f" % dist) + " Meters\n" + secText + String("%0.2f" % collision) + " Seconds"
|
||||
|
||||
func calcColDist(_delta) -> void:
|
||||
var rigidBody: RigidBody3D = $".."
|
||||
var rayCast: RayCast3D = $"../RayCast3D"
|
||||
var pos = rigidBody.global_position
|
||||
var linearVelocity = rigidBody.linear_velocity.normalized() * 100
|
||||
|
||||
rayCast.target_position = rigidBody.to_local(linearVelocity)
|
||||
# rayCast.rotation = rigidBody.rotation
|
||||
# rayCast.position = pos
|
||||
if rayCast.is_colliding():
|
||||
dist = (rayCast.get_collision_point() - pos).length() - 2.5 # Ship size-> eg. bounding box
|
||||
collision = dist / rigidBody.linear_velocity.length()
|
||||
if (collision <= 0.0):
|
||||
collision = 0.0
|
||||
|
||||
|
||||
else:
|
||||
dist = 0.0
|
||||
collision = 0.0
|
||||
1
Experiments/SpaceMove/Scripts/shipAiComponent.gd.uid
Normal file
1
Experiments/SpaceMove/Scripts/shipAiComponent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ci33hs6nbuhqr
|
||||
Reference in New Issue
Block a user