WIP: Not so much progress
This commit is contained in:
@ -27,31 +27,27 @@ var grav_vel: Vector3 # Gravity velocity
|
||||
var jump_vel: Vector3 # Jumping velocity
|
||||
|
||||
var is_crouch: bool = false
|
||||
|
||||
@onready var camera: Node3D = $UpperTorso
|
||||
@onready var character: Node3D = $"."
|
||||
|
||||
func get_current_camera() -> Camera3D:
|
||||
return $UpperTorso/ViewModelCamera
|
||||
|
||||
@onready var multiplayer_synchronizer = $"../MultiplayerSynchronizer"
|
||||
func _ready() -> void:
|
||||
set_process(get_multiplayer_authority() == multiplayer.get_unique_id())
|
||||
capture_mouse()
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
look_dir = event.relative * 0.001
|
||||
if mouse_captured: _rotate_camera()
|
||||
if Input.is_action_just_pressed("jump"): jumping = true
|
||||
if Input.is_action_just_pressed("jump"): _jump.rpc()
|
||||
if Input.is_action_just_pressed("exit"): get_tree().quit()
|
||||
if Input.is_action_just_pressed("shot"): $UpperTorso/ViewModelCamera.shot()
|
||||
if Input.is_action_just_pressed("reload"): $Body/UpperTorso/CameraMount/Camera.reload()
|
||||
if Input.is_action_just_pressed("crouch"): crouch()
|
||||
if Input.is_action_just_released("crouch"): uncrouch()
|
||||
#if Input.is_action_just_pressed("reload"): $Body/UpperTorso/CameraMount/Camera.reload()
|
||||
#if Input.is_action_just_pressed("crouch"): crouch()
|
||||
#if Input.is_action_just_released("crouch"): uncrouch()
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if mouse_captured: _handle_joypad_camera_rotation(delta)
|
||||
velocity = _walk(delta) + _gravity(delta) + _jump(delta)
|
||||
|
||||
move_and_slide()
|
||||
|
||||
func capture_mouse() -> void:
|
||||
@ -105,10 +101,9 @@ func _gravity(delta: float) -> Vector3:
|
||||
grav_vel = Vector3.ZERO if is_on_floor() else grav_vel.move_toward(Vector3(0, velocity.y - gravity, 0), gravity * delta)
|
||||
return grav_vel
|
||||
|
||||
@rpc("call_local")
|
||||
func _jump(delta: float) -> Vector3:
|
||||
if jumping:
|
||||
if is_on_floor(): jump_vel = Vector3(0, sqrt(4 * jump_height * gravity), 0)
|
||||
jumping = false
|
||||
return jump_vel
|
||||
#if is_on_floor(): jump_vel = Vector3(0, sqrt(4 * jump_height * gravity), 0)
|
||||
#return jump_vel
|
||||
jump_vel = Vector3.ZERO if is_on_floor() else jump_vel.move_toward(Vector3.ZERO, gravity * delta)
|
||||
return jump_vel
|
||||
|
11
scripts/player_input.gd
Normal file
11
scripts/player_input.gd
Normal file
@ -0,0 +1,11 @@
|
||||
extends MultiplayerSynchronizer
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
Reference in New Issue
Block a user