Split client and server
This commit is contained in:
7
client/player/Player.gd
Normal file
7
client/player/Player.gd
Normal file
@ -0,0 +1,7 @@
|
||||
class_name Player
|
||||
extends Character
|
||||
|
||||
func _ready():
|
||||
var controller := PlayerController.new()
|
||||
controller.character = self
|
||||
add_child(controller)
|
34
client/player/Player.tscn
Normal file
34
client/player/Player.tscn
Normal file
@ -0,0 +1,34 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://2lcnu3dy54lx"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/Player.gd" id="1_8gebs"]
|
||||
[ext_resource type="PackedScene" uid="uid://2bbycjulf00g" path="res://character/HealthComponent.tscn" id="2_np5ag"]
|
||||
[ext_resource type="Script" path="res://player/PlayerController.gd" id="3_oox5k"]
|
||||
|
||||
[sub_resource type="PrismMesh" id="PrismMesh_y7abh"]
|
||||
size = Vector3(0.5, 1.6, 0.5)
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2f50n"]
|
||||
radius = 0.25
|
||||
height = 1.6
|
||||
|
||||
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("model") groups=["player"]]
|
||||
script = ExtResource("1_8gebs")
|
||||
model = NodePath("Model")
|
||||
|
||||
[node name="Model" type="Node3D" parent="."]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Model"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
|
||||
mesh = SubResource("PrismMesh_y7abh")
|
||||
|
||||
[node name="Collision" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
|
||||
shape = SubResource("CapsuleShape3D_2f50n")
|
||||
|
||||
[node name="Animation" type="AnimationPlayer" parent="."]
|
||||
|
||||
[node name="Health" parent="." instance=ExtResource("2_np5ag")]
|
||||
|
||||
[node name="Controller" type="Node" parent="." node_paths=PackedStringArray("character")]
|
||||
script = ExtResource("3_oox5k")
|
||||
character = NodePath("..")
|
22
client/player/PlayerController.gd
Normal file
22
client/player/PlayerController.gd
Normal file
@ -0,0 +1,22 @@
|
||||
class_name PlayerController
|
||||
extends Node
|
||||
|
||||
## The character that we're controlling.
|
||||
@export var character: Character
|
||||
|
||||
var move: Vector2
|
||||
|
||||
func _input(_event):
|
||||
move = Input.get_vector("move_left", "move_right", "move_forward", "move_backward")
|
||||
character.direction = (Global.camera.transform.basis * Vector3(move.x, 0, move.y))
|
||||
character.direction.y = 0
|
||||
character.direction = character.direction.normalized()
|
||||
|
||||
if Input.is_action_just_pressed("jump"):
|
||||
character.jump()
|
||||
|
||||
if Input.is_action_just_pressed("dash"):
|
||||
character.dash()
|
||||
|
||||
if Input.is_action_just_pressed("attack"):
|
||||
character.attack()
|
Reference in New Issue
Block a user