Godot Version
4.4 Beta 4
Question
Hi, all. I am making a game where you can place cards and they will move toward the enemy’s towers, very similar to Clash Royale. Currently, players can enter a match with another player, and the server.
The server is able to spawn the troops with multiplayerspawner, and everything looks great, until it’s time to shoot. The tanks will see each other, shoot, and boom, the clients crash. Using breakpoints, it seems that on the host, everything works fine; the tank instantiates the bullet node, and applies values to the instantiated bullet’s variables, like it’s target and damage.
However, the clients just crash after adding the bullet as a sibling! The tanks instantiate the bullet, but they do not apply any values to the variables!! It is all null. Target = null, damage = null, everything is null. However, it still will finish, and add_sibling(bulletinstance). It will then crash, because “target” is nil.
func _on_attack_time_timeout() -> void:
#print("attack time timeout happened, attempting to do takedamage()")
#closest_enemy_in_attack_range.TakeDamage(Damage, "Melee")
var bulletinstance = slinger_bullet.instantiate()
bulletinstance.projectiledamage = Damage
if is_instance_valid(closest_enemy_in_attack_range) == false:
Get_Closest_Enemy_In_Attack()
bulletinstance.target = closest_enemy_in_attack_range
bulletinstance.position = self.global_position
add_sibling(bulletinstance)