Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | decord |
Good evening, I want to transmit head rotation to the server, but when I try to do this, nothing comes out, other players do not see your turn, help me please
server player script
extends Spatial
onready var head = $Head
onready var head_x = $Head/HeadXRotation
remote func update_player(transform):
rpc_unreliable(“update_remote_player”, transform)
remote func update_remote_head_rotation(head_rotation_x, head_rotation):
rpc_unreliable(“update_head_rotation”, head.rotation_degrees.y, head_x.rotation_degrees.x)
Client player script
func _input(event):
if is_network_master():
if not note_picked:
if event is InputEventMouseMotion:
head.rotation_degrees.y += sensitivity * event.relative.x
head_x.rotation_degrees.x += sensitivity * event.relative.y
head_x.rotation_degrees.x = clamp(head_x.rotation_degrees.x, -89, 89)
elif event is InputEventKey:
if Input.is_action_just_pressed(“flashlight”) and event.pressed and progressflash > 0:
timer2 = 0
flashlight_light.visible = !flashlight_light.visible
flashlight_sound.play()
elif event.scancode == KEY_SHIFT:
is_shift_pressed = event.pressed
elif Input.is_action_just_pressed(“duck”) and event.pressed:
is_crouching = !is_crouching
if is_crouching:
head.translation.y = CROUCH_HEIGHT
else:
head.translation.y = STAND_HEIGHT
elif event is InputEventMouseButton and not note_picked:
if is_mouse_captured:
# release the mouse capture and hide the cursor
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
is_mouse_captured = false
note_picked = false
else:
# capture the mouse and show the cursor
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
is_mouse_captured = true
var head_rotation_x = head_x.rotation_degrees.x
var head_rotation = head.rotation_degrees.y
rpc_unreliable_id(1, “update_remote_head_rotation”, head_rotation_x, head_rotation)
remote func update_head_rotation(head_rotation_x, head_rotation):
if not is_network_master():
head.rotation_degrees.y = head_rotation
head_x.rotation_degrees.x = head_rotation_x