Files
chameleon/Assets/Scripts/InsectMode.cs
T
adminandClaude Opus 4.8 cd40f42386 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>
2026-06-24 07:27:17 +02:00

39 lines
1.1 KiB
C#

/// <summary>
/// Insect / surface-walk mode: the player crawls along any surface (walls, ceilings,
/// arbitrary slopes) via <see cref="InsectController"/>. The gravity-based
/// <see cref="PlayerCharacterController"/> is disabled so the two never fight. The
/// camera keeps its world-up orbit; painting is off.
/// </summary>
public class InsectMode : GameMode
{
public override string DisplayName => "Insect";
public override void Enter()
{
if (Manager.Player)
Manager.Player.enabled = false; // stop the gravity controller (its Update/gravity)
if (Manager.Insect)
{
Manager.Insect.enabled = true;
Manager.Insect.ControlEnabled = true;
Manager.Insect.SnapToSurface();
}
if (Manager.CameraInput)
Manager.CameraInput.LookMode = ThirdPersonOrbitInput.OrbitLookMode.AlwaysActive;
if (Manager.Painter)
Manager.Painter.PaintingEnabled = false;
}
public override void Exit()
{
if (Manager.Insect)
Manager.Insect.enabled = false;
if (Manager.Player)
Manager.Player.enabled = true;
}
}