gamemode spawning
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user