This commit introduces a new custom character controller and updates the Trooper prefab with the following changes: - Add a new `CapsuleColliderCast` script to the custom character controller - Update the near clip plane of the Trooper's camera to 0.01 for better visibility - Update the package reference for the custom character controller to use the new package name `com.robotfireopenteam.customcharactercontroller` - Add a new component to the Trooper's Camera GameObject These changes are aimed at improving the character controller functionality and visual quality of the Trooper prefab.
47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
using System;
|
|
using Unity.Netcode;
|
|
using UnityEngine;
|
|
|
|
public class PlayerModel : NetworkBehaviour
|
|
{
|
|
public override void OnNetworkSpawn()
|
|
{
|
|
base.OnNetworkSpawn();
|
|
|
|
// Исключаем слой ModelLocal из рендеринга для mainCamera
|
|
if (IsLocalPlayer)
|
|
{
|
|
SetLayerRecursively(gameObject, LayerMask.NameToLayer("ModelRemote"));
|
|
}
|
|
else
|
|
{
|
|
SetLayerRecursively(gameObject, LayerMask.NameToLayer("ModelLocal"));
|
|
}
|
|
Debug.Log($"NetworkObject ID: {NetworkObjectId} RobotModel's LayerMask: " + gameObject.layer);
|
|
}
|
|
public override void OnNetworkDespawn()
|
|
{
|
|
base.OnNetworkDespawn();
|
|
}
|
|
|
|
void SetLayerRecursively(GameObject obj, int newLayer)
|
|
{
|
|
if (obj == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
obj.layer = newLayer;
|
|
|
|
foreach (Transform child in obj.transform)
|
|
{
|
|
if (child == null)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
SetLayerRecursively(child.gameObject, newLayer);
|
|
}
|
|
}
|
|
}
|