Skip to content
RustPluginGenerator

OnPlayerColliderEnable

OnPlayerColliderEnable is called from BasePlayer.EnablePlayerCollider just before the player's capsule collider is enabled again. Returning a non-null value blocks that enable, so the collider stays disabled.

Signature
object OnPlayerColliderEnable(BasePlayer player, UnityEngine.CapsuleCollider playerCollider)

Parameters

Hook parameters
ParameterTypeDescription
playerBasePlayerThe BasePlayer whose physics capsule collider is about to be re-enabled. Use it for permission checks, team lookups or to send feedback.
playerColliderUnityEngine.CapsuleColliderThe CapsuleCollider component on the player that EnablePlayerCollider is about to switch on. Inspect or adjust its radius, height or center before the game re-enables it.

Return value

Returning null lets the original code continue: it refreshes the collider size and sets playerCollider.enabled = true. Returning any non-null object stops the original method before that assignment, so the collider is left disabled. Since EnablePlayerCollider returns void, the value itself is discarded — only null versus non-null matters.

How it works

This hook fires inside BasePlayer.EnablePlayerCollider. The original method only does work when three conditions hold: the collider is currently disabled, the hook returns null, and the player is not an invisible server-side entity (base.isServer & isInvisible). So the hook runs on the common path where the game is about to restore collision for a player, typically after a jump, mount, vanish or teleport cycle moved them through a collider-disabled state.

The player parameter is the affected BasePlayer; use it for permissions, teams or chat feedback. The playerCollider parameter is the live CapsuleCollider, so you can read or change its radius, height and center before the engine enables it. Declaring player as a more specific type is pointless here since it is always a BasePlayer.

Because the game calls this on routine movement, keep the handler cheap: no Puts, no timers per call, no data writes. Return null unless you deliberately want the collider to remain off. Blocking the enable for a normal player will leave them without physics collision while the game thinks nothing is wrong.

Example plugin: Keep invisible staff free of collision

ColliderGhostMode.cs
using System.Linq;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("ColliderGhostMode", "RustPluginGenerator", "1.0.0")]
    [Description("Lets admins toggle a collision-free ghost mode by blocking their player collider from being re-enabled.")]
    public class ColliderGhostMode : RustPlugin
    {
        private const string PermUse = "colliderghostmode.use";

        private PluginConfig config;
        private StoredData data;

        private class PluginConfig
        {
            [JsonProperty("Send chat feedback")]
            public bool Feedback { get; set; } = true;
        }

        private class StoredData
        {
            [JsonProperty("Ghosted player ids")]
            public HashSet<string> Ghosted { get; set; } = new HashSet<string>();
        }

        protected override void LoadDefaultConfig() => config = new PluginConfig();

        protected override void LoadConfig()
        {
            base.LoadConfig();
            try
            {
                config = Config.ReadObject<PluginConfig>();
                if (config == null) throw new Exception();
            }
            catch
            {
                PrintWarning("Configuration file is invalid, using defaults");
                LoadDefaultConfig();
            }
            SaveConfig();
        }

        protected override void SaveConfig() => Config.WriteObject(config);

        protected override void LoadDefaultMessages()
        {
            lang.RegisterMessages(new Dictionary<string, string>
            {
                ["Enabled"] = "Ghost mode enabled. Collision is now disabled.",
                ["Disabled"] = "Ghost mode disabled. Collision restored.",
                ["NoPerm"] = "You do not have permission to use ghost mode."
            }, this);
        }

        private string Msg(string key, string userId = null, params object[] args) => string.Format(lang.GetMessage(key, this, userId), args);

        private void Init()
        {
            permission.RegisterPermission(PermUse, this);
            data = Interface.Oxide.DataFileSystem.ReadObject<StoredData>(Name) ?? new StoredData();
        }

        private void Unload()
        {
            foreach (var player in BasePlayer.activePlayerList)
            {
                if (player == null || !data.Ghosted.Contains(player.UserIDString)) continue;
                var capsule = player.GetComponent<CapsuleCollider>();
                if (capsule != null) capsule.enabled = true;
            }
            Interface.Oxide.DataFileSystem.WriteObject(Name, data);
        }

        [ChatCommand("collidergm")]
        private void CmdGhost(BasePlayer player, string command, string[] args)
        {
            if (player == null) return;
            if (!permission.UserHasPermission(player.UserIDString, PermUse))
            {
                player.ChatMessage(Msg("NoPerm", player.UserIDString));
                return;
            }

            var capsule = player.GetComponent<CapsuleCollider>();
            if (data.Ghosted.Contains(player.UserIDString))
            {
                data.Ghosted.Remove(player.UserIDString);
                if (capsule != null) capsule.enabled = true;
                if (config.Feedback) player.ChatMessage(Msg("Disabled", player.UserIDString));
            }
            else
            {
                data.Ghosted.Add(player.UserIDString);
                if (capsule != null) capsule.enabled = false;
                if (config.Feedback) player.ChatMessage(Msg("Enabled", player.UserIDString));
            }
            Interface.Oxide.DataFileSystem.WriteObject(Name, data);
        }

        private object OnPlayerColliderEnable(BasePlayer player, CapsuleCollider playerCollider)
        {
            if (player == null || playerCollider == null) return null;
            if (!data.Ghosted.Contains(player.UserIDString)) return null;

            return true;
        }
    }
}

The plugin adds a collidergm chat command restricted by the colliderghostmode.use permission. Toggling adds the player's user ID to a saved set in oxide/data and disables their capsule collider through playerCollider.enabled. From then on, when BasePlayer.EnablePlayerCollider runs for that player, OnPlayerColliderEnable returns a non-null value, which makes the game skip re-enabling the collider, so the admin can walk through walls and other players without being pushed. Toggling again removes the ID, and the next enable call is allowed to proceed. Unload re-enables colliders for everyone still flagged, so a reload never leaves an admin stuck with a disabled capsule.

Common use cases

  • Ghost mode for staff

    Block the collider for admins who need to inspect bases without being blocked by walls or pushed by other players.

  • Spectator collision control

    Keep the collider off while a player is in a custom spectator mode and allow it again when they return to normal play.

  • Collider diagnostics

    Read the radius, height and center of the capsule during the enable call to detect players stuck in unusual collision shapes and log a summary.

Pitfalls

  • Blocking normal players breaks physics

    Returning non-null for regular players leaves them without a capsule collider, so they can pass through geometry and fall through terrain. Only block for players you explicitly manage.

  • Called frequently, keep it cheap

    The hook runs whenever a player's collider is re-enabled during normal movement. Avoid string formatting, disk access or timers in the handler.

  • Invisible server entities skip the path

    The original method already does nothing when the player is an invisible server-side entity, so the hook is not the only reason a collider stays off. Reset state in Unload to avoid stuck players.

Build a plugin with OnPlayerColliderEnable

Describe what should happen and get a compiled plugin that uses this hook.

Prompt: Ghost mode for staff using the OnPlayerColliderEnable hook, with a config file and a permission
Generate this plugin

Edit the prompt on the next screen. 2 free plugins a month, no card.

Last updated Oct 26, 2026. Found a mistake? Email support@rustplugingenerator.com.

Build a plugin with OnPlayerColliderEnable

Generate