Godot can't synchronize spawned nodes

this is probably gonna end up being the most useless godot post because it’s really long and has acheived nothing.

ok the rotation issue has been fixed but the menu and bullet parent issue is still unfixed

I guess a little more context would allow us to help. I think just showing errors isn’t much to go on most of the time. I only know errors I’ve seen. And we are changing the topic many times already there really hasn’t been a goal post to reach.

The set index issue is a little cryptic to me. But I assume this is the issue.

bullet_direction is Vector2
bullet.direction is not Vector2 ?

The .direction isn’t a default property that exists on any node you are using, so what is it?

If your bullet code is still similar to what you first posted there is no property direction to be set. It doesn’t exist.

basically it was a custom property in the bullet that I forgot to set up.

var direction = Vector2.ZERO
1 Like

ok at this point it’s best I just send the project file

project file: (GitHub - funnimonkedev/projectfileforthemultipllayerthing: the project file for my godot forum error: https://forum.godotengine.org/t/godot-cant-synchronize-spawned-nodes/47315/46)

Hi funnimonkedev,
Did you solve the problem? I have the same error and im turning crazy :frowning:

I don’t fricking know, yeah, just take a break from your project and do something else. A good idea would be to literally copy the code that @bepis sent dtgreene/godot-multiplayer-example (github.com)

haven’t done this yet but it might actually fix it, just copying it.

completely.

these errors are so insane, someone should make a information video or tutorial on it, because there is nothing online with a fix.

I did notice something with your player script in the github thing, I tried to replace your code and adapt it for a platformer character but that does not work as intended, when it walks on another sprite like a tiilemap it gets stuck, and the bullets don’t move exactly to the mouse and move with an offest.

extends CharacterBody2D

const SPEED = 300.0
const position_update_rate = Globals.peer_update_rate
const position_update_min = 0.02
const JUMP_VELOCITY = -400.0
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")

@onready var color = MPlay.player_color
@onready var main_game = get_node("/root/MainGame")
@onready var shoot_timer = $ShootTimer
@onready var viewport = get_viewport()
@onready var update_override_timer = $UpdateOverrideTimer
var can_shoot = true
var prev_position = position
var position_tick = 0
var update_override = false
@onready var camera_2d = $Camera2D

func _ready():
	shoot_timer.timeout.connect(_handle_shoot_timeout)
	update_override_timer.timeout.connect(_handle_update_override_timeout)
	
	enable_update_override()

func _physics_process(delta):
	if is_multiplayer_authority(): camera_2d.enabled = true
	#if not is_multiplayer_authority(): return
	# Add the gravity.
	if not is_on_floor():
		velocity.y += gravity * delta

	# Handle jump.
	#and is_on_floor()
	if Input.is_action_just_pressed("move_up"):
		velocity.y = JUMP_VELOCITY

	var direction = Input.get_axis("move_left", "move_right")
	if direction:
		velocity.x = direction * SPEED
	else:
		velocity.x = move_toward(velocity.x, 0, SPEED)

	move_and_slide()
	
	
	##################### END OF MOVEMENT BEGGINING OF EVERYTHING ELSE I GUESS?? ##############################

func _process(delta):
	if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) and can_shoot:
		var mouse_position = viewport.get_mouse_position()
		var shoot_direction = (mouse_position - position).normalized()

		main_game.create_bullet.rpc(position, shoot_direction)
		
		can_shoot = false
		shoot_timer.start()
	
	# Send updates whenever our player moves by some threshold
	position_tick += 1
	if position_tick >= position_update_rate or update_override:
		position_tick = 0
		
		var position_needs_update = (position - prev_position).length() > position_update_min
		
		if position_needs_update or update_override:
			main_game.peer_update.rpc(_get_update_data())
		
		prev_position = position

func _handle_update_override_timeout():
	update_override = false

func _get_update_data():
	# Pack whatever data is needed to update the player. In this example, we only need the position.
	var data = PackedByteArray()
	data.resize(8)
	data.encode_float(0, position.x)
	data.encode_float(4, position.y)
	
	return data

func _handle_shoot_timeout():
	can_shoot = true

func enable_update_override():
	# Update override is used to manually force updates; usually when other players join.
	# Since updates are only sent when players move around, joining players won't know the positions of idle players until they move.
	# One alternative to this would be for players to send their position to joining players.  This is just easier and works.
	update_override = true
	update_override_timer.start()

(I have tried putting the mouse in the physics process as well)

you know what just have this topic close.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.