TargetToggleandBosstargetting
Adds a configurable hotkey to switch between Closest Enemy, Smart Aim in real time and Boss projectile targeting support, with a visible indicator on the HUD at the bottom right.
About this mod Author’s original text
TargetToggle — Megabonk Mod
A BepInEx (IL2CPP) mod that adds two configurable hotkeys to toggle targeting behavior in real time, with a HUD indicator in the bottom-right corner that only appears during a run.
Features
- Targeting mode toggle — switch between Closest Enemy and Smart Aim on the fly
- Boss Focus toggle — when active, prioritizes any boss over regular enemies. Falls back to your chosen targeting mode if no boss is in range
- In-game HUD — shows current state in the bottom-right corner, only visible during a run
- Fully configurable hotkeys — edit the BepInEx config file to use any key you want
Requirements
| Dependency | Version |
|---|---|
| BepInEx IL2CPP Pack | 6.0.738+ |
|.NET SDK (to compile) | 6.0+ |
| Megabonk | latest |
Installation
- Make sure BepInEx IL2CPP is installed in your Megabonk folder.
- Compile the project or download the release.dll.
- Place TargetToggleMod.dll in BepInEx/plugins.
- Launch the game once — BepInEx will generate the config file automatically.
Default Hotkeys
| Key | Action |
|---|---|
| T | Toggle between Closest Enemy and Smart Aim |
| Y | Toggle Boss Focus mode |
Configuration
Edit the generated config file at:
BepInEx/config/com.tuusuario.targettoggle.cfg
[Hotkeys]
ToggleTargetingMode = T
ToggleBossFocus = Y
Any Unity KeyCode value is valid — see the full list at:
HUD
- Appears only during a run (hidden in menus and loading screens)
- Displays the current targeting mode and boss focus state:
- TARGET: Closest / TARGET: Smart Aim
- TARGET: Closest | BOSS when Boss Focus is active
- Text turns yellow when Boss Focus is enabled
- Flashes briefly when you press a hotkey to confirm the change
How It Works
This mod uses a Harmony patch on EnemyTargeting.GetTargetedEnemy() to intercept targeting in real time — no save file modification needed.
- Closest Enemy: directly calls GetClosestEnemy(), skipping the default logic
- Smart Aim: lets the original method run normally
- Boss Focus: scans colliders for any enemy with EEnemyFlag.AnyBoss and targets the closest one. If no boss is found, falls back to the active targeting mode
Project Structure
TargetToggleMod/
├── TargetTogglePlugin.cs — main plugin (hotkeys, HUD, Harmony patch)
├── MyPluginInfo.cs — GUID, name, version
├── TargetToggleMod.csproj — C# project with BepInEx references
├── manifest.json — package manifest
├── icon.png — 256x256 mod icon
└── README.md — this file
License
MIT — do whatever you want with the code.
Install & use Install: follow the bundled instructions
- Unzip the archive from playbuff and read the bundled readme / instructions first.
- Most mods rely on the game's mod loader — the usual route is a community mod manager (such as r2modman): pick this game, install, and it handles the loader and dependencies.
- For a manual install, put the mod files into the matching Mod / plugins folder inside the game directory.
- Launch the game to confirm it loaded; mods with listed dependencies need those installed as well.
Install locations vary a lot between mods — the bundled readme is the most reliable guide.
Install these first, or the mod will not work: