4.4.1
Well, I’m making a multiplayer game and I’ve run into a situation. You see I need each player to spawn in a very specific spot. How can I achieve this?
Btw I am using multiplayercore plugin (If that changes anything)
4.4.1
Well, I’m making a multiplayer game and I’ve run into a situation. You see I need each player to spawn in a very specific spot. How can I achieve this?
Btw I am using multiplayercore plugin (If that changes anything)
player.global_position = spawn_point.global_position
You’ll have to rotate through spawn points as you iterate through players, but you can put them in an export variable array. Just use Marker2D or Marker3D nodes for the spawn points and make sure they’re high enough off the ground that your players don’t spawn inside the ground.
func OnPlayerReady():
print(“Positioning Players”)
var playerToSpawn = MultiplayerManager.player_scene.instantiate()
Here’s what I got although the player isn’t spawning though? This is in gamemanager (autoload)
and MultiplayerManager is also an autoload
Sorry for the late reply
playerToSpawn.global_position = spawn_point.global_position
And you need to define a spawn_point
.
Unfortunately, it would appear that we are in contradicting time zones, nevertheless I digress.
func OnPlayerReady():
print("Positioning Players")
var playerToSpawn = MultiplayerManager.player_scene.instantiate()
playerToSpawn.global_position = spawnPositions.front().global_position
The player still does not spawn, I can confirm that the spawnPositions array is filled.
You’re instantiating the player, but are you adding them to the scene tree? You still need an add_child(player)
or something.
func OnPlayerReady():
print("Positioning Players")
print(MultiplayerManager.player_scene)
var playerToSpawn: CharacterBody3D = MultiplayerManager.player_scene.instantiate()
var peerId = multiplayer.get_unique_id()
playerToSpawn.set_multiplayer_authority(peerId)
add_child(playerToSpawn)
#playerToSpawn.global_position = spawnPositions[0].global_position
#playerToSpawn.global_position = Vector3(spawnPositions.front().global_position.x, spawnPositions.front().global_position.y, spawnPositions.front().global_position.z )
playerToSpawn.global_position = spawnPositions[0].position
print("spawned player with authority for peer:", peerId)
I got this and the player is spawning now, although I can’t get them to move into position