stash changes added as intended

This commit is contained in:
ced
2026-07-17 17:52:55 -05:00
parent 66f3c13d61
commit 5b29f61df9
28 changed files with 118 additions and 81 deletions
+14 -11
View File
@@ -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)
@@ -124,6 +129,7 @@ func _physics_process(delta):
global_transform.basis = global_transform.basis.slerp(
target_basis, nose_align_speed * delta
)
func release_drag():
if not dragging:
@@ -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: