gamemode spawning

This commit is contained in:
2022-05-05 20:10:43 +03:00
parent fe443b9f50
commit c4f5d4d4d2
9 changed files with 101 additions and 45 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Linq;
using FlaxEngine;
using FlaxEngine.Networking;
using Console = Cabrito.Console;
@@ -11,7 +12,6 @@ namespace Game
{
NetworkManager.OnMessage += OnClientConnected;
Level.SceneLoaded += OnLevelLoaded;
Console.Print("level was loaded: " + Level.IsAnySceneLoaded);
}
public static void Cleanup()
@@ -28,6 +28,18 @@ namespace Game
public static bool OnClientConnected(NetworkMessage message)
{
Console.Print("client connected");
var spawns = Level.GetActors<Actor>().Where(x => x.Name.StartsWith("PlayerSpawn_")).ToArray();
Console.Print($"found {spawns.Length} spawns");
var randomSpawn = spawns.First();
PlayerActor localPlayerActor = Level.FindActor<PlayerActor>();
localPlayerActor.Teleport(randomSpawn.Position + new Vector3(0f, 4.1f, 0f), randomSpawn.Orientation.EulerAngles);
return true;
}
}