MV SDJB_UltimateCameraControl

PluginName: SDJB_UltimateCameraControl
Author: ShadowDragon

This Plugin is in WIP.

A powerful Camera Tool to Lock, Scroll, Target EventId, set position on x and y,
back to player, Zoom in/out, Scroll on region path, or common event when hitting
the edge while the camera scroll (like a platformer or challenge mode!)

Spoiler: How it works
Code:
 A powerful camera tool that lets you:
 → Lock the camera on X or Y axis
 → Automatically scroll in a direction (like auto-run or platformer levels)
 → Trigger common events when reaching camera edges (during autoScroll)
 → Target an event, set camera position manually
 → Zoom in/out dynamically
 → Follow paths via regions

 Camera X/Y Lock
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
 $gameSystem.setCameraLock(axis, lock, direction, loopJump, speed)
 axis      => "x" or "y"
 lock      => true or false => enables or disables lock
 direction => "left", "right" (for X), or "up", "down" (for Y)
 loopJump  => true/false    => if true, teleport player to opposite edge
 speed     => Number        => camera follow speed (default = 5)
 Notes:
 When direction is set to "both", the camera locks both directions
 on that axis.
 
 loopJump only works when direction is "both".
 Examples:
 $gameSystem.setCameraLock("x", true)               // Lock both X directions
 $gameSystem.setCameraLock("x", true, "left")       // Lock only left side of X
 $gameSystem.setCameraLock("x", true, "both", true) // Lock both and loop jump

 To unlock:
 $gameSystem.setCameraLock("x", false)
 $gameSystem.setCameraLock("x")                  // Equivalent to unlocking Y
 $gameSystem.resetCameraLock()                   // Unlock both "x" and "y"

 Automatic Scroll
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
 $gameSystem.setAutoScroll(direction, speed)
 direction => "up", "down", "left", "right"
 speed     => Number - how fast the camera scrolls (default = 0.05)

 Notes:
 Triggers when the player hits the camera edge. The effect is defined
 in the plugin parameter as any JS code that returns "true".
 Example: SceneManager.push(Scene_Gameover)
 
 Higher speed number scrolls faster, lower number scrolls slower.
 
 Auto-scrolling stops automatically if the camera can't scroll further
 (i.e., reached the edge of the map).
 
 Auto-scroll in the Y direction (up/down) may also cause camera movement
 on the X axis. To prevent this, use $gameSystem.setCameraLock("x", true)
 to lock the camera horizontally.

 Example:
 $gameSystem.setAutoScroll("up")           // Scrolls "up" at speed 0.05
 $gameSystem.setAutoScroll("up", 0.02)     // Scrolls "up" slower
 $gameSystem.clearAutoScroll()             // Stop auto-scrolling


 Scroll to Target
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
 Camera Sequence Script Call: $gameSystem.setCameraTo(steps)
 steps is an array of objects defining the camera movement sequence.

 Notes:
 The lock option only needs to be set once at the start of the sequence to
 lock player movement. Subsequent steps can omit it.

 The unlock option must be called at the end of the sequence (or during an event)
 to unlock player movement; omitting this will cause the game to freeze.

 Each step moves the camera based on the specified mode and parameters.

 The speed and wait parameters are optional; sensible defaults are used if omitted.

 Supported Modes and Options:

 mode: "static"  => Move camera to a fixed position.

 x: number (required)                  => target X coordinate
 y: number (required)                  => target Y coordinate
 lock: boolean (optional)              => lock player movement (only in first step)
 speed: number (optional, default 4)   => camera movement speed
 wait: number/string (optional)        => wait behavior (see below)


 mode: "event"  => Move camera to an event’s position.

 id: number (required) — event ID
 lock: boolean (optional)             => lock player movement (only in first step)
 speed: number (optional, default 4)  => camera movement speed
 wait: number/string (optional)       => wait behavior (see below)


 mode: "player"  => Focus camera on the player.

 unlock: boolean (optional, required at end) => unlock player movement
 speed: number (optional, default 4)         => camera movement speed
 wait: number/string (optional)              => wait behavior (see below)


 Wait Parameter Explanation:
 The wait parameter controls how the sequence progresses after the
 camera arrives at the target.

 Omitted or true    => Wait until arrival, then immediately continue to next step.
 false              => Same as above — no extra wait, continue immediately.
 Number (e.g., 60)  => Wait until arrival, then pause for given number of frames.
 String "true+N"    => Same as number — wait arrival plus N frames (for readability).

 Scriptcalls examples:
 $gameSystem.setCameraTo([
     {mode: "event", id: 1, lock: true, speed: 6, wait: true}
 ]);

 $gameSystem.setCameraTo([
     {mode: "event", id: 1, lock: true, speed: 6, wait: true},
     {mode: "player", speed: 4, wait: "true+60"},
     {mode: "event", id: 2, speed: 5, wait: 30},
     {mode: "static", x: 5, y: 5, speed: 3, wait: false},
     {mode: "static", x: 25, y: 15, speed: 6},
     {mode: "player", unlock: true}
 ]);

 Returning camera back to player
 You can also return the camera smoothly to the player position with:

 $gameMap.returnToPlayer(); // speed = 4
 $gameMap.returnToPlayer(speed); // adjust speed
 
 speed is optional; controls how fast the camera moves back to the player.


 Zoom in/out
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
 [Planned feature]

 Implement zooming with stable centering.
 Support zoom-in above 100% (e.g., 150%-200%) and limited zoom-out
 below 100% (down to ~50%) where possible.
 Handle edge triggers and auto-scroll properly while zoomed.


 Scroll Path by Region
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
 [Planned feature]

 Lock camera movement inside defined map regions.
 Prevent camera from moving outside specified region boundaries.
 Allow smooth zone transitions (like Zelda style screen shifts).
 Optionally integrate with auto-scroll for fun camera paths.

 Example Plugin Commands:
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
 [Planned feature]
 Under construction

Stages for release:
- When Lock Camera has full features
- After target xy, eventId, player position
- After Zoom in/out where able
- Full control over almost everything I can think off

What would be possible on full release:
with little eventing, Zelda transitions (not automatic!)

platform levels or other mechanic that camera scroll, hit the
edge = game over!

look around the map by x tiles using mouse or by holding a button down.

and many more (when I'm able to do them and inside my range,
but I keep trying to give you all the best features I can offer.

=== TERMS OF USE ===
Free for Non-Commercial and Commercial use when credit is given.
credit one of the following:
ShadowDragon
ShadowDragonJB

Version + UPDATE'S
28-07-2025 Version 1.0.0 first release


=== WARNING ===
YOU ARE NOT ALLOWED TO REDISTRIBUTE OR SELL IT OR TAKE CODE FOR YOUR OWN.
DO NOT REMOVE THE HEADER.

(it require my base plugin (SDJB_Base) MV ONLY!

Download it from itch.io
updated Description (I cannot guaranteed that it works in MZ.
if you want to test in MZ, let me know (plugin commands
will be excluded for MZ as scriptcalls can work.

I hope to get the first version what it can do (focused on Lock Camera)
around this or next week for you to try =)

This is the beginning of the huge challenge ahead ^^
First version released, what it covers:

Lock Camera (able to loopjump when touches the edges (X on both, or Y on both)
Lock Camera Direction "left", "right", "down", "up" and scroll 1 way only.
autoScroll function for platformer or running away!

this is the main focus and first release, so you can make endless looped hallway
or a platformer to autoscroll.

careful though, autoScroll has an edge trigger!

Enjoy the first release (requires MV 1.6.x and Nwjs 0.48.4+)
wont work on lower versions.
New update is released:

Target event ID, position X Y and, player in a smooth way.
adjust speed (default 4).

Fixes loopJump on cliff (by using a region ID).
Fixed adjustX and adjustY aliased from my based (of a mistake)

Region ID is not in the helpfile (will be there next update.
this Region ID is when you see part of a cliff, while loopJump is true,
you can go on it (sometimes not get off, which make the player stuck).

this region ID avoid from jumping on it.

Enjoy this new update 🙂

Next update will be zoom in/out (when I'm able and where possible.

leave suggestion/feedback behind, and your though how you like this plugin 🙂

Original thread: https://forums.rpgmakerweb.com/threads/sdjb_ultimatecameracontrol.179144/