init
This commit is contained in:
4
.editorconfig
Normal file
4
.editorconfig
Normal file
@ -0,0 +1,4 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# Normalize EOL for all files that Git considers text files.
|
||||
* text=auto eol=lf
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Godot 4+ specific ignores
|
||||
.godot/
|
||||
/android/
|
BIN
assets/human_m/HumanAnimations_ColorPalette.png
Normal file
BIN
assets/human_m/HumanAnimations_ColorPalette.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
35
assets/human_m/HumanAnimations_ColorPalette.png.import
Normal file
35
assets/human_m/HumanAnimations_ColorPalette.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bpys3pyano7uj"
|
||||
path.s3tc="res://.godot/imported/HumanAnimations_ColorPalette.png-4cb29115dacd15b7302ef1f7c6150b5e.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/human_m/HumanAnimations_ColorPalette.png"
|
||||
dest_files=["res://.godot/imported/HumanAnimations_ColorPalette.png-4cb29115dacd15b7302ef1f7c6150b5e.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
BIN
assets/human_m/HumanM@Idle01-Idle02.fbx
Normal file
BIN
assets/human_m/HumanM@Idle01-Idle02.fbx
Normal file
Binary file not shown.
38
assets/human_m/HumanM@Idle01-Idle02.fbx.import
Normal file
38
assets/human_m/HumanM@Idle01-Idle02.fbx.import
Normal file
@ -0,0 +1,38 @@
|
||||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://ch2re600llmov"
|
||||
path="res://.godot/imported/HumanM@Idle01-Idle02.fbx-dad0028eb6f60de1824e3c04e4f5df2a.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/human_m/HumanM@Idle01-Idle02.fbx"
|
||||
dest_files=["res://.godot/imported/HumanM@Idle01-Idle02.fbx-dad0028eb6f60de1824e3c04e4f5df2a.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=true
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
_subresources={}
|
||||
fbx/importer=0
|
||||
fbx/allow_geometry_helper_nodes=false
|
||||
fbx/embedded_image_handling=1
|
BIN
assets/human_m/HumanM_Model.fbx
Normal file
BIN
assets/human_m/HumanM_Model.fbx
Normal file
Binary file not shown.
38
assets/human_m/HumanM_Model.fbx.import
Normal file
38
assets/human_m/HumanM_Model.fbx.import
Normal file
@ -0,0 +1,38 @@
|
||||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://wabn5wdgj1ea"
|
||||
path="res://.godot/imported/HumanM_Model.fbx-c10837705ce3af2d191a7eb68a0bfec6.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/human_m/HumanM_Model.fbx"
|
||||
dest_files=["res://.godot/imported/HumanM_Model.fbx-c10837705ce3af2d191a7eb68a0bfec6.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=true
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
_subresources={}
|
||||
fbx/importer=0
|
||||
fbx/allow_geometry_helper_nodes=false
|
||||
fbx/embedded_image_handling=1
|
1
icon.svg
Normal file
1
icon.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>
|
After Width: | Height: | Size: 994 B |
37
icon.svg.import
Normal file
37
icon.svg.import
Normal file
@ -0,0 +1,37 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bdcdt3hh1ud5a"
|
||||
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.svg"
|
||||
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
59
project.godot
Normal file
59
project.godot
Normal file
@ -0,0 +1,59 @@
|
||||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
config/name="test"
|
||||
run/main_scene="uid://8ywbh7j4mmai"
|
||||
config/features=PackedStringArray("4.4", "GL Compatibility")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[input]
|
||||
|
||||
move_left={
|
||||
"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":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_right={
|
||||
"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":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_forward={
|
||||
"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":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_backward={
|
||||
"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":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
jump={
|
||||
"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":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
shift={
|
||||
"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":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
toggle_mouse_capture={
|
||||
"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":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
renderer/rendering_method.mobile="gl_compatibility"
|
BIN
scenes/godot_plush_albedo.png
Normal file
BIN
scenes/godot_plush_albedo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
35
scenes/godot_plush_albedo.png.import
Normal file
35
scenes/godot_plush_albedo.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bqi8qqkfrh03v"
|
||||
path.s3tc="res://.godot/imported/godot_plush_albedo.png-ac2bb3d54c640f512b4e4e3e979e5b0b.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://scenes/godot_plush_albedo.png"
|
||||
dest_files=["res://.godot/imported/godot_plush_albedo.png-ac2bb3d54c640f512b4e4e3e979e5b0b.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
BIN
scenes/godot_plush_model.glb
Normal file
BIN
scenes/godot_plush_model.glb
Normal file
Binary file not shown.
37
scenes/godot_plush_model.glb.import
Normal file
37
scenes/godot_plush_model.glb.import
Normal file
@ -0,0 +1,37 @@
|
||||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://cg7of11dls47q"
|
||||
path="res://.godot/imported/godot_plush_model.glb-2a94ebc65a92c245a0230196c71a7989.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://scenes/godot_plush_model.glb"
|
||||
dest_files=["res://.godot/imported/godot_plush_model.glb-2a94ebc65a92c245a0230196c71a7989.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=false
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
_subresources={}
|
||||
gltf/naming_version=1
|
||||
gltf/embedded_image_handling=1
|
29
scenes/level.tscn
Normal file
29
scenes/level.tscn
Normal file
@ -0,0 +1,29 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://8ywbh7j4mmai"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dsrbro31ggv7u" path="res://scenes/player.tscn" id="1_2q6dc"]
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_rd3vj"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_w7c3h"]
|
||||
albedo_color = Color(5.41471e-08, 0.281997, 1.44392e-07, 1)
|
||||
|
||||
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_2q6dc"]
|
||||
|
||||
[node name="level" type="Node3D"]
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="StaticBody3D"]
|
||||
transform = Transform3D(10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0)
|
||||
mesh = SubResource("PlaneMesh_rd3vj")
|
||||
skeleton = NodePath("../..")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_w7c3h")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
|
||||
shape = SubResource("WorldBoundaryShape3D_2q6dc")
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("1_2q6dc")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0640043, 0.486621, -0.407444)
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 4, -1)
|
1546
scenes/player.tscn
Normal file
1546
scenes/player.tscn
Normal file
File diff suppressed because one or more lines are too long
29
scripts/3d_godot_robot.gd
Normal file
29
scripts/3d_godot_robot.gd
Normal file
@ -0,0 +1,29 @@
|
||||
extends Node3D
|
||||
class_name Body
|
||||
|
||||
const LERP_VELOCITY: float = 0.15
|
||||
|
||||
@export_category("Objects")
|
||||
@export var _character: CharacterBody3D = null
|
||||
@export var animation_player: AnimationPlayer = null
|
||||
|
||||
func animate(_velocity: Vector3) -> void:
|
||||
if not _character.is_on_floor():
|
||||
if _velocity.y < 0:
|
||||
animation_player.play("fall")
|
||||
else:
|
||||
animation_player.play("up")
|
||||
return
|
||||
|
||||
if _velocity.length() > 0.1: # Если есть движение
|
||||
if _character.is_running():
|
||||
animation_player.play("run") # Спринт
|
||||
else:
|
||||
animation_player.play("walk") # Обычная ходьба
|
||||
return
|
||||
|
||||
animation_player.play("idle") # Бездействие
|
||||
|
||||
@rpc("any_peer", "reliable")
|
||||
func sync_player_rotation(rotation_y: float) -> void:
|
||||
rotation.y = rotation_y
|
1
scripts/3d_godot_robot.gd.uid
Normal file
1
scripts/3d_godot_robot.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://3antcjs38iwb
|
82
scripts/player.gd
Normal file
82
scripts/player.gd
Normal file
@ -0,0 +1,82 @@
|
||||
extends CharacterBody3D
|
||||
class_name Character
|
||||
|
||||
@export_group("Movement Settings")
|
||||
@export var normal_speed: float = 6.0
|
||||
@export var sprint_speed: float = 10.0
|
||||
@export var jump_velocity: float = 10.0
|
||||
@export var gravity_scale: float = 1.0 # Позволяет регулировать гравитацию
|
||||
@export var rotation_speed: float = 10.0
|
||||
|
||||
@export_group("References")
|
||||
@export var body: Node3D = null
|
||||
@export var spring_arm_offset: Node3D = null
|
||||
@export var respawn_point: Vector3 = Vector3(0, 5, 0)
|
||||
|
||||
var _current_speed: float
|
||||
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
||||
|
||||
func _ready():
|
||||
$SpringArmOffset/SpringArm3D/Camera3D.current = false
|
||||
|
||||
func _physics_process(delta):
|
||||
var current_scene = get_tree().get_current_scene()
|
||||
|
||||
if not is_on_floor():
|
||||
velocity.y -= gravity * delta
|
||||
|
||||
if is_on_floor():
|
||||
if Input.is_action_just_pressed("jump"):
|
||||
velocity.y = jump_velocity
|
||||
else:
|
||||
velocity.y -= gravity * delta
|
||||
|
||||
_move()
|
||||
move_and_slide()
|
||||
|
||||
if body and body.has_method("animate"):
|
||||
body.animate(velocity)
|
||||
|
||||
func _process(_delta):
|
||||
_check_fall_and_respawn()
|
||||
|
||||
func freeze():
|
||||
velocity.x = 0
|
||||
velocity.z = 0
|
||||
_current_speed = 0
|
||||
|
||||
func _move() -> void:
|
||||
var input_direction = Input.get_vector("move_left", "move_right", "move_forward", "move_backward")
|
||||
|
||||
# Получаем направление движения относительно камеры
|
||||
var camera_basis = $SpringArmOffset/SpringArm3D/Camera3D.global_transform.basis
|
||||
var direction = (camera_basis * Vector3(input_direction.x, 0, input_direction.y)).normalized()
|
||||
|
||||
_update_speed()
|
||||
|
||||
if direction:
|
||||
velocity.x = direction.x * _current_speed
|
||||
velocity.z = direction.z * _current_speed
|
||||
|
||||
# Поворачиваем тело персонажа в направлении движения
|
||||
if velocity.length() > 0.1: # Только если есть значительное движение
|
||||
var target_rotation = atan2(velocity.x, velocity.z)
|
||||
body.rotation.y = lerp_angle(body.rotation.y, target_rotation, rotation_speed * get_process_delta_time())
|
||||
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, _current_speed)
|
||||
velocity.z = move_toward(velocity.z, 0, _current_speed)
|
||||
|
||||
func is_running() -> bool:
|
||||
return Input.is_action_pressed("shift") and _current_speed == sprint_speed
|
||||
|
||||
func _update_speed() -> void:
|
||||
_current_speed = sprint_speed if Input.is_action_pressed("shift") else normal_speed
|
||||
|
||||
func _check_fall_and_respawn():
|
||||
if global_transform.origin.y < -15.0:
|
||||
_respawn()
|
||||
|
||||
func _respawn():
|
||||
global_transform.origin = respawn_point
|
||||
velocity = Vector3.ZERO
|
1
scripts/player.gd.uid
Normal file
1
scripts/player.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://c34hkc8bu3wrg
|
28
scripts/spring_arm_offset.gd
Normal file
28
scripts/spring_arm_offset.gd
Normal file
@ -0,0 +1,28 @@
|
||||
extends Node3D
|
||||
class_name SpringArmCharacter
|
||||
|
||||
const MOUSE_SENSIBILITY: float = 0.005
|
||||
|
||||
@export_category("Objects")
|
||||
@export var _spring_arm: SpringArm3D = null
|
||||
|
||||
var mouse_captured: bool = true
|
||||
|
||||
func _ready():
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) # Захватываем мышь при старте
|
||||
|
||||
func _unhandled_input(event) -> void:
|
||||
if event.is_action_pressed("ui_cancel") or event.is_action_pressed("toggle_mouse_capture"):
|
||||
toggle_mouse_capture()
|
||||
|
||||
if mouse_captured and (event is InputEventMouseMotion):
|
||||
rotate_y(-event.relative.x * MOUSE_SENSIBILITY)
|
||||
_spring_arm.rotate_x(-event.relative.y * MOUSE_SENSIBILITY)
|
||||
_spring_arm.rotation.x = clamp(_spring_arm.rotation.x, -PI/4, PI/24)
|
||||
|
||||
func toggle_mouse_capture():
|
||||
mouse_captured = !mouse_captured
|
||||
if mouse_captured:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
else:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
1
scripts/spring_arm_offset.gd.uid
Normal file
1
scripts/spring_arm_offset.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://7ddexruyiiqd
|
Reference in New Issue
Block a user