Files
stickman/scripts/prop_trajectory.gd
ryan 043f114083 Implement interactive prop handling for StickmanRig
- Added PropTrajectory class for deterministic ballistic calculations.
- Introduced StickmanPropInteraction component to manage prop interactions (pickup, drop, throw).
- Implemented grip resolution and attachment logic for props.
- Added signals for interaction events (prop_picked_up, prop_dropped, prop_thrown).
- Defined specifications for prop interaction lifecycle and event rules.
- Ensured compatibility with existing prop systems and added new capabilities for prop pickup.
2026-09-23 21:26:13 -04:00

18 lines
985 B
GDScript

class_name PropTrajectory
extends RefCounted
## Shared deterministic ballistic solver for director feedback and playback.
const MIN_FLIGHT_TIME: float = 0.35
const MAX_FLIGHT_TIME: float = 1.5
const MAX_LAUNCH_SPEED: float = 900.0
static func solve_throw_velocity(release_point: Vector2, target_point: Vector2, flight_time: float, gravity_vector: Vector2) -> Dictionary:
if not release_point.is_finite() or not target_point.is_finite() or not gravity_vector.is_finite():
return {"ok": false, "reason": "non_finite"}
if not is_finite(flight_time) or flight_time < MIN_FLIGHT_TIME or flight_time > MAX_FLIGHT_TIME:
return {"ok": false, "reason": "flight_time"}
var velocity: Vector2 = (target_point - release_point - gravity_vector * 0.5 * flight_time * flight_time) / flight_time
if not velocity.is_finite() or velocity.length() > MAX_LAUNCH_SPEED:
return {"ok": false, "reason": "speed"}
return {"ok": true, "velocity": velocity, "flight_time": flight_time, "reason": ""}