codeAPI Reference
s&box RollermineNpc: Physics-driven NPC
RollermineNpc Class API Reference
RollermineNpc is a physics-driven NPC that chases players, leaps at them, and bounces off dealing damage on contact. Implements IDamageable and ICollisionListener.
Type Signature
CSHARP
public class RollermineNpc : Npc, Component.IDamageable, Component.ICollisionListener
{
[Property, ClientEditable, Range(1f, 500f), Sync] public float Health { get; set; } = 35f;
[Property, Group("Balance")] public float RollForce { get; set; } = 80000f;
[Property, Group("Balance")] public float RollTorque { get; set; } = 40000f;
[Property, Group("Balance")] public float StuckJumpForce { get; set; } = 500f;
[Property, Group("Balance")] public float LeapForce { get; set; } = 60000f;
[Property, Group("Balance")] public float LeapUpwardBias { get; set; } = 0.2f;
[Property, Group("Balance")] public float BounceForce { get; set; } = 450f;
[Property, Group("Balance")] public float ContactDamage { get; set; } = 20f;
[Property, Group("Balance")] public float LeapRange { get; set; } = 160f;
[Property] public GameObject Eye { get; set; }
[Property, Group("Effects")] public GameObject HuntingEffects { get; set; }
[Property, Group("Effects")] public GameObject LeapEffect { get; set; }
[Property, Group("Effects")] public GameObject ContactEffect { get; set; }
[Property, Group("Effects")] public SoundEvent RollSound { get; set; }
[Property, Group("Effects")] public float PitchSpeedMax { get; set; } = 600f;
[Property, Group("Effects")] public float PitchMin { get; set; } = 0.6f;
[Property, Group("Effects")] public float PitchMax { get; set; } = 1.6f;
public void SetHunting(bool hunting);
[Rpc.Broadcast] public void BroadcastLeapEffect();
[Rpc.Broadcast] public void BroadcastContactEffect(Vector3 position);
}Properties
Balance:
- float RollForce { get; set; } = 80000f - Continuous force while rolling
- float RollTorque { get; set; } = 40000f - Torque for visual spin
- float StuckJumpForce { get; set; } = 500f - Upward impulse when stuck
- float LeapForce { get; set; } = 60000f - Impulse when leaping
- float LeapUpwardBias { get; set; } = 0.2f - Upward component of leap (0-1)
- float BounceForce { get; set; } = 450f - Bounce impulse magnitude
- float ContactDamage { get; set; } = 20f - Damage on contact
- float LeapRange { get; set; } = 160f - Distance to switch to leaping
Effects:
- GameObject Eye { get; set; } - Eye child GameObject, rotated to face target
- GameObject HuntingEffects { get; set; } - Particle effects while hunting
- GameObject LeapEffect { get; set; } - Prefab cloned when leaping
- GameObject ContactEffect { get; set; } - Prefab cloned on contact
- SoundEvent RollSound { get; set; } - Looping roll sound (pitch driven by speed)
Methods
SetHunting(bool hunting)
Toggles hunting state, enables/disables effects, expands collider radius.BroadcastLeapEffect()
Broadcast RPC that clones LeapEffect at current position.BroadcastContactEffect(Vector3 position)
Broadcast RPC that clones ContactEffect at hit position.IDamageable Implementation
- OnDamage(in DamageInfo damage) - Reduces health, dies when <= 0
ICollisionListener Implementation
- OnCollisionStart(Collision collision) - Deals ContactDamage to damageable targets, bounces away with cooldown
Usage
CSHARP
// Create a rollermine
var npc = GameObject.Components.Create<RollermineNpc>();
npc.ContactDamage = 30f;
npc.LeapForce = 80000f;Notes
- Uses schedules: RollermineChaseSchedule, RollermineIdleSchedule
- Roll sound pitch scales with velocity
- Eye tracks nearest visible target
- Bounces up and away from targets
Was this helpful?