Marek Fix
This commit is contained in:
@@ -182,6 +182,7 @@ namespace MegaKoop.Game.Networking
|
||||
var clone = Instantiate(template, spawnPosition, baseRotation, parent);
|
||||
clone.name = BuildPlayerName(info, i);
|
||||
|
||||
AdjustSpawnToGround(clone);
|
||||
ConfigureCloneForPlayer(clone, info, i);
|
||||
|
||||
ulong ownerSteamId = ParseSteamId(info.SteamId);
|
||||
@@ -252,6 +253,25 @@ namespace MegaKoop.Game.Networking
|
||||
return center + offset;
|
||||
}
|
||||
|
||||
private void AdjustSpawnToGround(GameObject clone)
|
||||
{
|
||||
if (clone == null) return;
|
||||
var t = clone.transform;
|
||||
var cc = clone.GetComponent<CharacterController>();
|
||||
Vector3 pos = t.position;
|
||||
float up = 2.5f;
|
||||
float down = 10f;
|
||||
float radius = cc != null ? cc.radius : 0.25f;
|
||||
Vector3 origin = pos + Vector3.up * up;
|
||||
if (Physics.SphereCast(origin, Mathf.Max(0.05f, radius * 0.9f), Vector3.down, out RaycastHit hit, up + down, ~0, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
float centerY = cc != null ? cc.center.y : 0f;
|
||||
float height = cc != null ? cc.height : 2f;
|
||||
float targetY = hit.point.y + (height * 0.5f) - centerY + 0.02f;
|
||||
t.position = new Vector3(pos.x, targetY, pos.z);
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfigureCloneForPlayer(GameObject clone, LobbyPlayerInfo info, int index)
|
||||
{
|
||||
// Ensure network identity is deterministic across clients.
|
||||
|
||||
Reference in New Issue
Block a user