CHARACTER MOVEMENT SCRIPT
@export var speed = 700
@export var camera_slowness = 7000
@onready var y_pivot = get_node("y_Pivot")
@onready var x_pivot = get_node("y_Pivot/x_Pivot2")
@onready var camera = $y_Pivot/x_Pivot2/Camera3D
func _ready():
set_multiplayer_authority(name.to_int())
camera.current = is_multiplayer_authority()
func _physics_process(delta):
if not is_multiplayer_authority(): return
var foward_back_direction = ((global_position - get_node("FollowNode").global_position) * speed) * delta
var left_right_direction = ((global_position - get_node("FollowNode2").global_position) * speed) * delta
if Input.is_action_pressed("walk forward"):
apply_central_force(-foward_back_direction)
if Input.is_action_pressed("walk back"):
apply_central_force(foward_back_direction)
if Input.is_action_pressed("walk right"):
apply_central_force(left_right_direction)
if Input.is_action_pressed("walk left"):
apply_central_force(-left_right_direction)
func _input(event):
if not is_multiplayer_authority(): return
if event is InputEventMouseMotion and Input.is_action_pressed("pan_cam"):
event.velocity /= camera_slowness
y_pivot.rotation.y -= event.velocity.x
x_pivot.rotation.x -= event.velocity.y
