système de sauvegarde, scène 3D de test sur la base astra et passage en forward+

This commit is contained in:
2026-02-06 10:28:36 +01:00
parent 83d462f2f4
commit cc421a951f
97 changed files with 2138 additions and 1007 deletions

View File

@@ -0,0 +1,70 @@
extends CharacterBody3D
const POINTER_TEXTURE = preload("res://common/icons/focus.svg")
const POINTER_ACTION_TEXTURE = preload("res://common/icons/hand-stop.svg")
@export var pointer_texture_rect : TextureRect
const SPEED = 4.0
const MOUSE_SENSIVITY = 0.002
const RAY_LENGTH = 10.
var cockpit_action_hovered : CockpitAction = null
var query_mouse := false
func _input(event):
if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
rotate_y(-event.relative.x * MOUSE_SENSIVITY)
%Camera3D.rotate_x(-event.relative.y * MOUSE_SENSIVITY)
%Camera3D.rotation.x = clampf($Camera3D.rotation.x, -deg_to_rad(70), deg_to_rad(70))
query_mouse = true
if event.is_action_pressed("action") and cockpit_action_hovered and cockpit_action_hovered:
cockpit_action_hovered.click()
func _physics_process(delta):
if query_mouse:
update_mouse_hovered_cockpit_actions()
%PointerTexture.texture = (
POINTER_ACTION_TEXTURE if cockpit_action_hovered != null
else POINTER_TEXTURE
)
query_mouse = false
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
move_and_slide()
func update_mouse_hovered_cockpit_actions() -> void:
var space_state = get_world_3d().direct_space_state
var middle_screen = get_viewport().get_visible_rect().size / 2
var from = %Camera3D.project_ray_origin(middle_screen)
var to = from + %Camera3D.project_ray_normal(middle_screen) * RAY_LENGTH
var query = PhysicsRayQueryParameters3D.create(from, to)
query.collide_with_areas = true
var result = space_state.intersect_ray(query)
if result and result.collider and result.collider is CockpitAction and result.collider.pickable:
if cockpit_action_hovered and cockpit_action_hovered != result.collider:
cockpit_action_hovered._on_mouse_exited()
cockpit_action_hovered = result.collider
cockpit_action_hovered._on_mouse_entered()
else :
if cockpit_action_hovered:
cockpit_action_hovered._on_mouse_exited()
cockpit_action_hovered = null

View File

@@ -0,0 +1 @@
uid://3rrym6yv7xyp