basic player movement
This commit is contained in:
parent
e973ab13ec
commit
2ce0a460ac
4 changed files with 58 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
|||
[gd_scene load_steps=10 format=3 uid="uid://dwx5tcatj35gu"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://dwx5tcatj35gu"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dts8lbivkgsmj" path="res://base/scripts/player/player.gd" id="1_1w3ab"]
|
||||
[ext_resource type="Texture2D" uid="uid://cf7avgppv4kfk" path="res://base/assets/guns/placeholder/static.png" id="1_7s1wv"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfw6p5g680c55" path="res://base/assets/guns/placeholder/shoot1.png" id="2_7ptt8"]
|
||||
[ext_resource type="Texture2D" uid="uid://bwfkjfpk4dwx0" path="res://base/assets/guns/placeholder/shoot2.png" id="3_1w3ab"]
|
||||
|
@ -63,13 +64,18 @@ _data = {
|
|||
&"static": SubResource("Animation_ma1q3")
|
||||
}
|
||||
|
||||
[node name="Player" type="RigidBody3D"]
|
||||
[node name="Player" type="CharacterBody3D"]
|
||||
collision_layer = 2
|
||||
collision_mask = 3
|
||||
platform_wall_layers = 1
|
||||
script = ExtResource("1_1w3ab")
|
||||
|
||||
[node name="Collider" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("CapsuleShape3D_jjqxs")
|
||||
|
||||
[node name="Camera" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
current = true
|
||||
|
||||
[node name="HUD" type="CanvasLayer" parent="."]
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
[node name="Test Room" type="Node3D"]
|
||||
|
||||
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="."]
|
||||
use_collision = true
|
||||
collision_mask = 2
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="CSGCombiner3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.165546, -1.07088, 0.522302)
|
||||
|
|
|
@ -1,12 +1,27 @@
|
|||
extends RigidBody3D
|
||||
extends CharacterBody3D
|
||||
|
||||
@export var speed = 100.0
|
||||
@export var fall_acceleration = 75.0
|
||||
|
||||
var stack: CommandStack = CommandStack.new()
|
||||
|
||||
@onready var weapon_player: AnimationPlayer = $"HUD/Weapon/AnimationPlayer"
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
weapon_player.current_animation = "static"
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
func _physics_process(delta: float) -> void:
|
||||
var direction = Vector3.ZERO
|
||||
direction.z = Input.get_axis("move_forward", "move_backward")
|
||||
direction.x = Input.get_axis("move_left", "move_right")
|
||||
|
||||
var target_velocity = direction * speed * delta
|
||||
|
||||
if not is_on_floor():
|
||||
target_velocity.y -= fall_acceleration * delta
|
||||
|
||||
velocity = target_velocity
|
||||
move_and_slide()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue