Add insect surface-walker controller and mode

Add InsectController (transform-driven SphereCast surface following, no
CharacterController/Rigidbody, no gravity or slope limit) and InsectMode as a
third game mode. Wire it into GameModeManager with conditional registration so
PlayerControl and Insect modes only join the Tab cycle when their controller is
present. PaintMode/PlayerControlMode toggle the insect controller accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 4.8 committed 2026-06-24 07:27:17 +02:00
1 parent dbf5104611
commit cd40f42386
7 files changed
+405 -1

No files matched your search

+16 -1
View File
@@ -22,6 +22,9 @@ public class GameModeManager : MonoBehaviour
[Tooltip("Mesh painter. Empty = found automatically.")]
public MeshPainter painter;
[Tooltip("Insect / surface-walk controller. Empty = found automatically.")]
public InsectController insect;
[Header("Switching")]
[Tooltip("Key that cycles to the next mode.")]
#if ENABLE_INPUT_SYSTEM
@@ -36,6 +39,7 @@ public class GameModeManager : MonoBehaviour
public PlayerCharacterController Player => player;
public ThirdPersonOrbitInput CameraInput => cameraInput;
public MeshPainter Painter => painter;
public InsectController Insect => insect;
private readonly List<GameMode> _modes = new List<GameMode>();
private int _activeIndex = -1;
@@ -49,6 +53,7 @@ public class GameModeManager : MonoBehaviour
if (!player) player = FindFirstObjectByType<PlayerCharacterController>();
if (!cameraInput) cameraInput = FindFirstObjectByType<ThirdPersonOrbitInput>();
if (!painter) painter = FindFirstObjectByType<MeshPainter>();
if (!insect) insect = FindFirstObjectByType<InsectController>();
BuildModes();
}
@@ -63,9 +68,19 @@ public class GameModeManager : MonoBehaviour
private void BuildModes()
{
_modes.Clear();
_modes.Add(new PlayerControlMode());
// Player Control only joins the Tab cycle when a gravity player is present, so a scene
// running only the insect walker doesn't trap input in a dead, player-freezing mode.
if (player)
_modes.Add(new PlayerControlMode());
_modes.Add(new PaintMode());
// Insect mode only joins the Tab cycle when a surface walker is present, so a scene
// without one behaves exactly as before (no dead, player-freezing mode in the cycle).
if (insect)
_modes.Add(new InsectMode());
foreach (var m in _modes)
m.Bind(this);
}