Player
This commit is contained in:
parent
3479e3c6a5
commit
fbde622d85
4 changed files with 123 additions and 0 deletions
|
@ -11,5 +11,42 @@ config_version=5
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Gj 803z 2024"
|
config/name="Gj 803z 2024"
|
||||||
|
run/main_scene="res://scenes/World.tscn"
|
||||||
config/features=PackedStringArray("4.2", "Forward Plus")
|
config/features=PackedStringArray("4.2", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/viewport_width=1920
|
||||||
|
window/size/viewport_height=1080
|
||||||
|
window/size/mode=2
|
||||||
|
window/size/resizable=false
|
||||||
|
window/size/borderless=true
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
move_forward={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"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":122,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_left={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"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":113,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_backward={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"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,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"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,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
[rendering]
|
||||||
|
|
||||||
|
lights_and_shadows/directional_shadow/soft_shadow_filter_quality=3
|
||||||
|
anti_aliasing/quality/msaa_3d=1
|
||||||
|
|
18
scenes/Player.tscn
Normal file
18
scenes/Player.tscn
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://b78y8nhrad6ag"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/Player.gd" id="1_ady3x"]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_568l5"]
|
||||||
|
|
||||||
|
[node name="Player" type="RigidBody3D"]
|
||||||
|
lock_rotation = true
|
||||||
|
linear_damp = 3.0
|
||||||
|
script = ExtResource("1_ady3x")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
shape = SubResource("CapsuleShape3D_568l5")
|
||||||
|
|
||||||
|
[node name="Head" type="Node3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
|
||||||
|
|
||||||
|
[node name="Camera3D" type="Camera3D" parent="Head"]
|
42
scenes/World.tscn
Normal file
42
scenes/World.tscn
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
[gd_scene load_steps=7 format=3 uid="uid://dc0cngrxpqgyh"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b78y8nhrad6ag" path="res://scenes/Player.tscn" id="1_r5ocp"]
|
||||||
|
|
||||||
|
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_uwb5b"]
|
||||||
|
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
|
||||||
|
ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
|
||||||
|
|
||||||
|
[sub_resource type="Sky" id="Sky_viuhm"]
|
||||||
|
sky_material = SubResource("ProceduralSkyMaterial_uwb5b")
|
||||||
|
|
||||||
|
[sub_resource type="Environment" id="Environment_665ea"]
|
||||||
|
background_mode = 2
|
||||||
|
sky = SubResource("Sky_viuhm")
|
||||||
|
tonemap_mode = 2
|
||||||
|
glow_enabled = true
|
||||||
|
|
||||||
|
[sub_resource type="PlaneMesh" id="PlaneMesh_vfc5y"]
|
||||||
|
size = Vector2(10, 10)
|
||||||
|
|
||||||
|
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_ibbj3"]
|
||||||
|
data = PackedVector3Array(5, 0, 5, -5, 0, 5, 5, 0, -5, -5, 0, 5, -5, 0, -5, 5, 0, -5)
|
||||||
|
|
||||||
|
[node name="World" type="Node3D"]
|
||||||
|
|
||||||
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||||
|
environment = SubResource("Environment_665ea")
|
||||||
|
|
||||||
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||||
|
transform = Transform3D(-0.866025, -0.433013, 0.25, 0, 0.5, 0.866025, -0.5, 0.75, -0.433013, 0, 0, 0)
|
||||||
|
shadow_enabled = true
|
||||||
|
|
||||||
|
[node name="Floor" type="MeshInstance3D" parent="."]
|
||||||
|
mesh = SubResource("PlaneMesh_vfc5y")
|
||||||
|
|
||||||
|
[node name="StaticBody3D" type="StaticBody3D" parent="Floor"]
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor/StaticBody3D"]
|
||||||
|
shape = SubResource("ConcavePolygonShape3D_ibbj3")
|
||||||
|
|
||||||
|
[node name="Player" parent="." instance=ExtResource("1_r5ocp")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.1, 0)
|
26
scripts/Player.gd
Normal file
26
scripts/Player.gd
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
extends RigidBody3D
|
||||||
|
|
||||||
|
@onready var head := $Head
|
||||||
|
|
||||||
|
const SPEED := 1200.0
|
||||||
|
const MOUSE_SENSITIVITY := 0.15
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
# Change input mode
|
||||||
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
|
|
||||||
|
# Called at each input
|
||||||
|
func _input(event):
|
||||||
|
if event is InputEventMouseMotion:
|
||||||
|
rotate_y(-deg_to_rad(event.relative.x * MOUSE_SENSITIVITY))
|
||||||
|
head.rotate_x(-deg_to_rad(event.relative.y * MOUSE_SENSITIVITY))
|
||||||
|
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-89), deg_to_rad(89))
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta):
|
||||||
|
# Movement
|
||||||
|
var input := Vector3.ZERO
|
||||||
|
input.x = Input.get_axis("move_left", "move_right")
|
||||||
|
input.z = Input.get_axis("move_forward", "move_backward")
|
||||||
|
apply_central_force(basis * input.normalized() * SPEED * delta)
|
Reference in a new issue