spacing in player
This commit is contained in:
parent
db0ea23ea8
commit
428c0a1f52
@ -45,6 +45,7 @@ func _enter_tree() -> void:
|
||||
camera.current = true
|
||||
capture_mouse()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if !is_network_authority: return
|
||||
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
@ -57,6 +58,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
if Input.is_action_just_pressed("jump") and !is_piloting:
|
||||
jumping = true
|
||||
|
||||
|
||||
func _input(event):
|
||||
if !is_network_authority: return
|
||||
if event.is_action_pressed("esc") and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
@ -64,6 +66,7 @@ func _input(event):
|
||||
elif event.is_action_pressed("esc") and not Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
capture_mouse()
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if !is_network_authority: return
|
||||
if current_ship != null:
|
||||
@ -82,6 +85,7 @@ func _physics_process(delta: float) -> void:
|
||||
_handle_joypad_camera_rotation(delta)
|
||||
move_and_slide()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if !is_network_authority: return
|
||||
|
||||
@ -93,14 +97,17 @@ func _process(delta: float) -> void:
|
||||
NetworkManager.sync_property(network_uuid, "global_rotation", global_rotation)
|
||||
previous_global_rotation = global_rotation
|
||||
|
||||
|
||||
func capture_mouse() -> void:
|
||||
if !is_network_authority: return
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
|
||||
func release_mouse() -> void:
|
||||
if !is_network_authority: return
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
|
||||
|
||||
func _rotate_camera(sens_mod: float = 1.0) -> void:
|
||||
if !is_network_authority: return
|
||||
var camera_sens_final = camera_sens
|
||||
@ -110,6 +117,7 @@ func _rotate_camera(sens_mod: float = 1.0) -> void:
|
||||
camera.rotation.y -= look_dir.x * camera_sens_final * sens_mod
|
||||
camera.rotation.x = clamp(camera.rotation.x - look_dir.y * camera_sens_final * sens_mod, -1.5, 1.5)
|
||||
|
||||
|
||||
func _handle_joypad_camera_rotation(delta: float, sens_mod: float = 1.0) -> void:
|
||||
var joypad_dir: Vector2 = Input.get_vector("look_left","look_right","look_up","look_down")
|
||||
if joypad_dir.length() > 0:
|
||||
@ -117,6 +125,7 @@ func _handle_joypad_camera_rotation(delta: float, sens_mod: float = 1.0) -> void
|
||||
_rotate_camera(sens_mod)
|
||||
look_dir = Vector2.ZERO
|
||||
|
||||
|
||||
func walk(delta: float) -> Vector3:
|
||||
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
move_dir = Input.get_vector("move_left", "move_right", "move_forwards", "move_backwards")
|
||||
@ -125,10 +134,12 @@ func walk(delta: float) -> Vector3:
|
||||
walk_vel = walk_vel.move_toward(walk_dir * speed * move_dir.length(), acceleration * delta)
|
||||
return walk_vel
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
func _jump(delta: float) -> Vector3:
|
||||
if jumping:
|
||||
if is_on_floor(): jump_vel = Vector3(0, sqrt(4 * jump_height * gravity), 0)
|
||||
@ -137,18 +148,21 @@ func _jump(delta: float) -> Vector3:
|
||||
jump_vel = Vector3.ZERO if is_on_floor() else jump_vel.move_toward(Vector3.ZERO, gravity * delta)
|
||||
return jump_vel
|
||||
|
||||
|
||||
func player_entered_ship(ship_global_position: Vector3, ship: Ship):
|
||||
if !is_network_authority: return
|
||||
current_ship = ship
|
||||
print(ship.ship_id)
|
||||
print(global_position)
|
||||
|
||||
|
||||
func player_exited_ship(ship_global_position: Vector3, ship: Ship):
|
||||
if !is_network_authority: return
|
||||
current_ship = null
|
||||
print(ship.ship_id)
|
||||
print(global_position)
|
||||
|
||||
|
||||
func set_is_piloting(state: bool):
|
||||
if !is_network_authority: return
|
||||
is_piloting = state
|
||||
|
Loading…
Reference in New Issue
Block a user