Compare commits
2
Commits
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
5b29f61df9 | ||
|
|
66f3c13d61 |
+5
-1
@@ -20,4 +20,8 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.10033989, 0)
|
||||
shape = SubResource("CapsuleShape3D_xxti7")
|
||||
|
||||
[node name="Dart2" parent="RigidBody3D" unique_id=1655536183 instance=ExtResource("2_mlvfh")]
|
||||
transform = Transform3D(0.4, 0, 0, 0, 0.39999995, 0, 0, 0, 0.39999995, 0, -1.4526575, 0.015561234)
|
||||
transform = Transform3D(0.4, 0, 0, 0, 0.39999995, 0, 0, 0, 0.39999995, 0, -1.4526575, 0.00214429)
|
||||
|
||||
[node name="RayCast3D" type="RayCast3D" parent="RigidBody3D" unique_id=892030560]
|
||||
transform = Transform3D(1, 0, 0, 0, -1, 8.742278e-08, 0, -8.742278e-08, -1, 0, 0.9578117, 0)
|
||||
collide_with_areas = true
|
||||
|
||||
+14
-11
@@ -2,6 +2,9 @@ extends RigidBody3D
|
||||
|
||||
class_name Dart
|
||||
|
||||
#ray cast
|
||||
@onready var point = $RayCast3D
|
||||
|
||||
#states
|
||||
var in_flight: bool = false
|
||||
var dragging: bool = false
|
||||
@@ -21,7 +24,7 @@ const HISTORY_LENGTH = 6
|
||||
@export var max_drag_speed: float = 42.0 # clamp so it doesn't go insane
|
||||
@export_range(-180,180) var angle_of_plane: float = 15.0
|
||||
@export var throw_force_multiplier: float = 0.8 # scale raw throw velocity down if it's too fast
|
||||
@export var max_throw_speed: float = 42.0 # hard cap so fast flicks don't kill the arc
|
||||
@export var max_throw_speed: float = 64.0 # hard cap so fast flicks don't kill the arc
|
||||
@export var flight_gravity_scale: float = 4.0 # higher = more visible arc
|
||||
@export var nose_align_speed: float = 1.0 # how fast dart rotates to face velocity
|
||||
@export var dart_forward_axis: Vector3 = Vector3.FORWARD
|
||||
@@ -46,7 +49,7 @@ func start_drag(camera: Camera3D, mouse_pos: Vector2, hit_point: Vector3):
|
||||
drag_plane = Plane(tilt.normalized(), hit_point)
|
||||
drag_offset = global_position - hit_point
|
||||
|
||||
target_pos = global_position #fixes a bug where dart drops until mouse is moved.
|
||||
target_pos = global_position #fixes a bug where dart drops until mouse is moved.m
|
||||
|
||||
position_history.clear()
|
||||
time_history.clear()
|
||||
@@ -98,13 +101,15 @@ func _physics_process(delta):
|
||||
if position_history.size() > HISTORY_LENGTH:
|
||||
position_history.pop_front()
|
||||
time_history.pop_front()
|
||||
elif point.is_colliding():
|
||||
var collider = point.get_collider()
|
||||
if collider and collider.is_in_group("dartable"):
|
||||
in_flight = false
|
||||
dragging = false
|
||||
await get_tree().create_timer(0.01).timeout
|
||||
freeze_mode = RigidBody3D.FREEZE_MODE_STATIC
|
||||
freeze = true
|
||||
elif in_flight:
|
||||
# Debug: confirm Y velocity is dropping (becoming negative) each frame
|
||||
print("local +X world dir: ", global_transform.basis.x)
|
||||
print("local +Y world dir: ", global_transform.basis.y)
|
||||
print("local +Z world dir: ", global_transform.basis.z)
|
||||
print("velocity dir: ", linear_velocity.normalized())
|
||||
|
||||
# Align dart nose to face velocity direction (tip points the way it's flying)
|
||||
if linear_velocity.length() > 0.5:
|
||||
_align_dart_to_velocity(delta)
|
||||
@@ -125,6 +130,7 @@ func _physics_process(delta):
|
||||
target_basis, nose_align_speed * delta
|
||||
)
|
||||
|
||||
|
||||
func release_drag():
|
||||
if not dragging:
|
||||
return
|
||||
@@ -141,9 +147,6 @@ func release_drag():
|
||||
linear_velocity = velocity
|
||||
# angular_velocity left as-is from physics, or compute your own spin here
|
||||
|
||||
print("throw speed: %.2f" % velocity.length())
|
||||
print("gravity_scale: ", gravity_scale)
|
||||
print("linear_damp: ", linear_damp)
|
||||
|
||||
func calculate_throw_velocity() -> Vector3:
|
||||
if position_history.size() < 2:
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
[ext_resource type="Script" uid="uid://d1i0lhibtflvq" path="res://Scripts/Main.gd" id="1_fq6v0"]
|
||||
[ext_resource type="Script" uid="uid://x5kcjofb5pek" path="res://Scripts/DropCatcher.gd" id="3_qdhrm"]
|
||||
[ext_resource type="Script" uid="uid://dnek55fao0l72" path="res://Scripts/ModifierTray.gd" id="5_kax6v"]
|
||||
[ext_resource type="PackedScene" uid="uid://6nml3641dpce" path="res://Models/Dartboard/Dartboard.glb" id="5_thh7l"]
|
||||
[ext_resource type="PackedScene" uid="uid://6nml3641dpce" path="res://models/Dartboard/Dartboard.glb" id="5_thh7l"]
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_qu08v"]
|
||||
height = 0.18115234
|
||||
radius = 0.96484375
|
||||
|
||||
[node name="DartboardProto" type="Node3D" unique_id=1829621191 node_paths=PackedStringArray("dartboard_root")]
|
||||
script = ExtResource("1_fq6v0")
|
||||
@@ -14,9 +18,15 @@ transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 2.65
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1020512688]
|
||||
|
||||
[node name="Dartboard" parent="." unique_id=1632971704 instance=ExtResource("5_thh7l")]
|
||||
[node name="Dartboard" parent="." unique_id=1632971704 groups=["dartable"] instance=ExtResource("5_thh7l")]
|
||||
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 0.16272092, 1.2674973, 0)
|
||||
|
||||
[node name="Area3D" type="Area3D" parent="Dartboard" unique_id=470399503 groups=["dartable"]]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Dartboard/Area3D" unique_id=2058320974]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0.003960803, 0.0015273094, 0.0637207)
|
||||
shape = SubResource("CylinderShape3D_qu08v")
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=80012783]
|
||||
|
||||
[node name="DropCatcher" type="Control" parent="CanvasLayer" unique_id=1371111637 node_paths=PackedStringArray("camera", "main")]
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var dart_camera = $Camera3D
|
||||
@onready var board_camera = $Board_camera
|
||||
var camera: bool = false
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event.is_action_pressed("restart"):
|
||||
get_tree().reload_current_scene()
|
||||
if event.is_action_pressed("camera"):
|
||||
dart_camera.current = camera
|
||||
board_camera.current = !camera
|
||||
camera = !camera
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
[ext_resource type="Script" uid="uid://geqmah8kbko0" path="res://Scenes/main.gd" id="1_8gbba"]
|
||||
[ext_resource type="Script" uid="uid://ds3uiri3oc05v" path="res://Scenes/camera_3d.gd" id="1_bo1nx"]
|
||||
[ext_resource type="PackedScene" uid="uid://bswbcehkkqbk0" path="res://Scenes/Dart.tscn" id="1_jjgbg"]
|
||||
[ext_resource type="PackedScene" uid="uid://cqe6bo8v564dc" path="res://Scenes/Dartboard-Proto.tscn" id="4_jjvhh"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_qu08v"]
|
||||
size = Vector3(1, 0.01, 1)
|
||||
@@ -38,3 +39,9 @@ shape = SubResource("BoxShape3D_qu08v")
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="StaticBody3D/CollisionShape3D" unique_id=849495197]
|
||||
mesh = SubResource("BoxMesh_xxti7")
|
||||
skeleton = NodePath("")
|
||||
|
||||
[node name="DartboardProto" parent="." unique_id=1829621191 groups=["dartable"] instance=ExtResource("4_jjvhh")]
|
||||
transform = Transform3D(-2.1855695e-07, 0, 5, 0, 5, 0, -5, 0, -2.1855695e-07, -0.38649988, 1.5309646, 18.770962)
|
||||
|
||||
[node name="Board_camera" type="Camera3D" parent="." unique_id=1404073028]
|
||||
transform = Transform3D(-0.6146763, 0, -0.78877944, 0, 1, 0, 0.78877944, 0, -0.6146763, -8.792414, 7.5380507, 13.506961)
|
||||
|
||||
@@ -4,12 +4,12 @@ importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://cjq45anerhxnk"
|
||||
path="res://.godot/imported/Dart.glb-e68d17366fac688e4c81cf4cc62e1175.scn"
|
||||
path="res://.godot/imported/Dart.glb-c455f16296a9e65bbb66a88577786d63.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://models/Dart.glb"
|
||||
dest_files=["res://.godot/imported/Dart.glb-e68d17366fac688e4c81cf4cc62e1175.scn"]
|
||||
source_file="res://Models/Dart.glb"
|
||||
dest_files=["res://.godot/imported/Dart.glb-c455f16296a9e65bbb66a88577786d63.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://62njxkpga6e8"
|
||||
path.s3tc="res://.godot/imported/Dart_Dart-Default.png-ffb5dce2e6bbf58fe2b00949ee100702.s3tc.ctex"
|
||||
path.s3tc="res://.godot/imported/Dart_Dart-Default.png-6f8aeb995de95881fb9c9013d8c53895.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
@@ -14,8 +14,8 @@ generator_parameters={
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://models/Dart_Dart-Default.png"
|
||||
dest_files=["res://.godot/imported/Dart_Dart-Default.png-ffb5dce2e6bbf58fe2b00949ee100702.s3tc.ctex"]
|
||||
source_file="res://Models/Dart_Dart-Default.png"
|
||||
dest_files=["res://.godot/imported/Dart_Dart-Default.png-6f8aeb995de95881fb9c9013d8c53895.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b7bsi4ury2lve"
|
||||
path.s3tc="res://.godot/imported/Dart_Wings-Default.png-dcf030c3d00e4d9573d0a3e9c88fff0a.s3tc.ctex"
|
||||
path.s3tc="res://.godot/imported/Dart_Wings-Default.png-5fe09a8386222e14f1aee4e3675a93cb.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
@@ -14,8 +14,8 @@ generator_parameters={
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://models/Dart_Wings-Default.png"
|
||||
dest_files=["res://.godot/imported/Dart_Wings-Default.png-dcf030c3d00e4d9573d0a3e9c88fff0a.s3tc.ctex"]
|
||||
source_file="res://Models/Dart_Wings-Default.png"
|
||||
dest_files=["res://.godot/imported/Dart_Wings-Default.png-5fe09a8386222e14f1aee4e3675a93cb.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
||||
+6
-1
@@ -35,6 +35,7 @@ import/blender/enabled=false
|
||||
[global_group]
|
||||
|
||||
Dart="All throwable darts"
|
||||
dartable="Surfaces that the dart can stick into"
|
||||
|
||||
[input]
|
||||
|
||||
@@ -46,7 +47,11 @@ leftClick={
|
||||
restart={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":16,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":16,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
camera={
|
||||
"deadzone": 0.2,
|
||||
"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":67,"key_label":0,"unicode":99,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user