Initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
|
||||
const SPEED = 5.0
|
||||
const JUMP_VELOCITY = 4.5
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity += get_gravity() * delta
|
||||
|
||||
# Handle jump.
|
||||
if Input.is_action_just_pressed("jump") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
|
||||
# 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("left", "right", "up", "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()
|
||||
@@ -0,0 +1 @@
|
||||
uid://bpuswe0lscol6
|
||||
@@ -0,0 +1,19 @@
|
||||
[gd_scene format=3 uid="uid://28vjund5bw4e"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bpuswe0lscol6" path="res://Player/player.gd" id="1_l8h54"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_6rmpw"]
|
||||
|
||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_6rmpw"]
|
||||
|
||||
[node name="Player" type="CharacterBody3D" unique_id=317650489]
|
||||
script = ExtResource("1_l8h54")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=747962587]
|
||||
shape = SubResource("CapsuleShape3D_6rmpw")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="." unique_id=1290238522]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.9396926, 0.34202012, 0, -0.34202012, 0.9396926, 1.5, 2, 3)
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=1886576590]
|
||||
mesh = SubResource("CapsuleMesh_6rmpw")
|
||||
Reference in New Issue
Block a user