How do I update the rotation in multiplayer, I am able to update the position but not sure about the rotation.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rakmot

For updating the movement, I use rpc_unreliable(“_set_position”, global_transform.origin) How would i use the same format to update the rotation of a character?

func _input(event):
if is_network_master():
if event is InputEventMouseMotion:
head.rotate_y(deg2rad(-event.relative.x * ms))

		var x_delta = event.relative.y * ms
		if camera_x_rotation + x_delta > -90 and camera_x_rotation + x_delta < 90:
			camera.rotate_x(deg2rad(-x_delta))
			camera_x_rotation += x_delta
rpc_unreliable("_input")

It is not working because it is not updating the character rotation. What can I do to resolve it?

rakmot | 2021-01-28 00:37

:bust_in_silhouette: Reply From: Lopy

Transforms are composed of two parts. A Vector3 called origin, representing the translation of your Spatial, and a Basis called basis, representing rotation and scale. Instead of only sending global_transform.origin, you could send the Transform directly. Either make your own function that sets the transform property on the other end, or use rset().

Note that you probably want to use transform instead of global_transform.

rpc_unreliable(“set”, [“transform”, transform])

Hello, thanks for responding. How would I write this in code?

rakmot | 2021-01-27 19:39

I tried to put transform.origin instead but there was no difference.

rakmot | 2021-01-27 19:42