système de sauvegarde, scène 3D de test sur la base astra et passage en forward+
This commit is contained in:
67
entities/player_3d/player_3D.tscn
Normal file
67
entities/player_3d/player_3D.tscn
Normal file
@@ -0,0 +1,67 @@
|
||||
[gd_scene format=3 uid="uid://da7a74dg30q1l"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://3rrym6yv7xyp" path="res://entities/player_3d/scripts/player_3d.gd" id="1_pvvbh"]
|
||||
[ext_resource type="Material" uid="uid://cr7bp4fhh1ipr" path="res://entities/player_3d/resources/materials/post_process_quad.tres" id="2_fcmrk"]
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/hud.tres" id="2_qi48i"]
|
||||
[ext_resource type="PackedScene" uid="uid://clicjf8ts51h8" path="res://gui/game/inventory_gui/inventory_gui.tscn" id="3_ea0v7"]
|
||||
[ext_resource type="Texture2D" uid="uid://ba8vh5h3r6pr2" path="res://common/icons/focus.svg" id="4_sbfo8"]
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_o44vi"]
|
||||
size = Vector2(2, 2)
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_eodxe"]
|
||||
radius = 0.46868896
|
||||
height = 1.7342377
|
||||
|
||||
[node name="Player3D" type="CharacterBody3D" unique_id=549819967 node_paths=PackedStringArray("pointer_texture_rect")]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, 0)
|
||||
script = ExtResource("1_pvvbh")
|
||||
pointer_texture_rect = NodePath("CanvasLayer/PointerTexture")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="." unique_id=2091917091]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.19785136, 0)
|
||||
near = 0.003
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Camera3D" unique_id=818458454]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.2)
|
||||
mesh = SubResource("QuadMesh_o44vi")
|
||||
surface_material_override/0 = ExtResource("2_fcmrk")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=456230433]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.253273, 0)
|
||||
shape = SubResource("CapsuleShape3D_eodxe")
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1210282091]
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="CanvasLayer" unique_id=355504485]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("2_qi48i")
|
||||
|
||||
[node name="Inventory" parent="CanvasLayer/MarginContainer" unique_id=820746652 instance=ExtResource("3_ea0v7")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
|
||||
[node name="PointerTexture" type="TextureRect" parent="CanvasLayer" unique_id=99628184]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(30, 30)
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -2.5
|
||||
offset_top = -2.5
|
||||
offset_right = 2.5
|
||||
offset_bottom = 2.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
texture = ExtResource("4_sbfo8")
|
||||
expand_mode = 1
|
||||
@@ -0,0 +1,12 @@
|
||||
[gd_resource type="ShaderMaterial" format=3 uid="uid://cr7bp4fhh1ipr"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://n6r7u234l2iy" path="res://common/vfx/materials/shaders/3d_outline_2.gdshader" id="1_tvsbc"]
|
||||
|
||||
[resource]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_tvsbc")
|
||||
shader_parameter/step_count = 3
|
||||
shader_parameter/thickness = 2.0000000149012003
|
||||
shader_parameter/edge_color = Color(0.0627451, 0.05882353, 0.16862746, 1)
|
||||
shader_parameter/fade_start = 100.0
|
||||
shader_parameter/fade_length = 200.0
|
||||
70
entities/player_3d/scripts/player_3d.gd
Normal file
70
entities/player_3d/scripts/player_3d.gd
Normal 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
|
||||
1
entities/player_3d/scripts/player_3d.gd.uid
Normal file
1
entities/player_3d/scripts/player_3d.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://3rrym6yv7xyp
|
||||
Reference in New Issue
Block a user