Galv’s Cam Control V.1.4

Demo – Version 1.4 >
NOTE: Currently only works correctly with default screen size.

#  Galv's Cam Control
#  Version 1.4
#  2013-03-18 - Version 1.4 - fixed a bug where it crashed if you didn't turn
#                           - off following an event when transferring to a map
#                           - without that event.
#  2013-03-18 - Version 1.3 - fixed a bug with parallax motion stopping
#  2013-03-04 - Version 1.2 - re-written script to scroll to targets
#  2012-10-24 - Version 1.1 - updated alias naming for compatability
#  2012-10-20 - Version 1.0 - release
#  This script allows some control over where the camera is through use of
#  script calls. You can fix the camera to a location on the map or follow an
#  event's movements.
#  cam_follow(event_id,speed)   # Camera follows event instead of player
#  cam_center(speed)            # Moves camera back to player
#  cam_set(x,y,speed)      # Position the camera centered on x, y coordinates
# # NOTE: speed can be 1 to 6 or you can leave it out of the script call to
#         default to 6. If you want to instantly snap the camera without it
#         scrolling, make speed 0
#  cam_set(10,5)         # Moves camera to map co-ordinates x 10, y5 at speed 6
#  cam_set(10,5,2)       # Moves camera to map co-ordinates x 10, y5 at speed 2
#  cam_follow(4)         # Moves camera to event 4's location and follows it.
#  cam_follow(4,0)       # SNAPS camera to event 4's location and follows it.
#  cam_center            # Moves camera to player at speed 6
#  cam_center(0)         # Snaps camera to player instantly
$imported = {} if $imported.nil?
$imported["Camera_Control"] = true
class Game_Map
  attr_accessor :cam_target
  alias galv_cam_control_gm_setup setup
  def setup(map_id)
    @cam_target = 0
    @scroll_blocked = false
  def scroll_to_target(x,y,speed)
    if @display_y.to_i < y && @display_x.to_i > x && can_move?(2) && can_move?(4)
      dir = 1
    elsif @display_y.to_i > y && @display_x.to_i > x && can_move?(8) && can_move?(4)
      dir = 7
    elsif @display_y.to_i > y && @display_x.to_i < x && can_move?(8) && can_move?(6)
      dir = 9
    elsif @display_y.to_i < y && @display_x.to_i < x && can_move?(2) && can_move?(6)
      dir = 3
    elsif @display_y.to_i < y && can_move?(2)
      dir = 2
    elsif @display_y.to_i > y && can_move?(8)
      dir = 8
    elsif @display_x.to_i < x && can_move?(6)
      dir = 6
    elsif @display_x.to_i > x && can_move?(4)
      dir = 4
      dir = 0
    if dir > 0
      start_scroll(dir, 1, speed)
      @scroll_blocked = false
      @scroll_blocked = true
    Fiber.yield while scrolling?
  def cannot_scroll?
    @scroll_blocked == true
  def can_move?(dir)
    case dir
    when 2; (@display_y % @map.height) < height - (Graphics.height / 32)
    when 4; (@display_x % @map.width) > 0
    when 6; (@display_x % @map.width) < width - (Graphics.width / 32)
    when 8; (@display_y % @map.height) > 0
  def do_scroll(dir, dis)
    case dir
    when 1
      scroll_down(dis); scroll_left(dis)
    when 2
    when 3
      scroll_down(dis); scroll_right(dis)
    when 4
    when 6
    when 7
      scroll_up(dis); scroll_left(dis)
    when 8
    when 9
      scroll_up(dis); scroll_right(dis)
  def set_event_display_pos(x, y)
    x = [0, [x, width - screen_tile_x].min].max unless loop_horizontal?
    y = [0, [y, height - screen_tile_y].min].max unless loop_vertical?
    @display_x = (x + width) % width
    @display_y = (y + height) % height
end # Game_Map
class Game_Player < Game_Character
  alias galv_cam_control_gp_update update
  def update
    if $game_map.cam_target > 0
      last_real_x = $[$game_map.cam_target].real_x
      last_real_y = $[$game_map.cam_target].real_y
      $game_map.set_event_display_pos(last_real_x - center_x, last_real_y - center_y)
  alias galv_cam_control_gp_update_scroll update_scroll
  def update_scroll(last_real_x, last_real_y)
    return if $game_map.cam_target != 0
    galv_cam_control_gp_update_scroll(last_real_x, last_real_y)
end # Game_Player < Game_Character
class Game_Interpreter
   def cam_center(speed = 6)
    $game_map.cam_target = -1
    scroll_to_event(0,speed) if speed != 0
    $game_map.set_display_pos($game_player.x - $game_player.center_x, $game_player.y - $game_player.center_y)
    $game_map.cam_target = 0
  def cam_set(x,y,speed = 6)
    $game_map.cam_target = -1
    scroll_to_target(x,y,speed) if speed != 0
    $game_map.set_display_pos(x - $game_player.center_x, y - $game_player.center_y)
  def scroll_to_target(x,y,speed)
    scroll_x = (x - $game_player.center_x).to_i
    scroll_y = (y - $game_player.center_y).to_i
    loop do
      if $game_map.display_x == scroll_x && $game_map.display_y == scroll_y ||
  def scroll_to_event(id,speed)
    if id > 0; char = $[id]
    else; char = $game_player; end
    loop do
      scroll_x = char.x - $game_player.center_x
      scroll_y = char.y - $game_player.center_y
      if $game_map.display_x == scroll_x && $game_map.display_y == scroll_y ||
  def cam_follow(event_id,speed = 6)
    $game_map.cam_target = -1
    scroll_to_event(event_id,speed) if speed != 0
    $game_map.cam_target = event_id
end # Game_Interpreter

39 thoughts on “Galv’s Cam Control V.1.4

  1. chaos17 says:

    Is it possible to make the sliding of the the camera more smooth/soft ?
    I mean when you setup the camera to follow an event, your script kinda jump/teleport on it.
    I tried to combine the scroll map function with your script call but it doesn’t work nicely because the screen still “jump” on the event.

    • Galv says:

      This is a pretty old script, I didn’t work out how to nicely do that at the time (I tried, though haha). I’ll take another look sometime soon and hopefully what I’ve learned will allow me to work it out.

  2. Galv says:

    I updated the script so it can scroll to target, can you please test it and let me know if you run into any troubles?

  3. Nosleinad says:

    I was using version 1.1 until now, thanks for the update Galv.
    I found one neat bug though while using the script call cam_follow(x): the parallax animation (that was moving) suddenly stops , and does not go back even if i center the camera on the player again. Ubfortunatelly no error messages appear to point it better.

  4. Galv says:

    Thanks for letting me know – I think I fixed the parallax stopping issue, please grab it from this page and see

  5. NobleD says:

    Hi! You might not know this…
    But you’re the Master of event utility scripts. :) I will use this wisely~ *have been searching days*
    Awesome script~!

  6. Hi! I’m not sure what happened here..

    This happened in map that did not have any cam script calls, and even when I do, it still happens.

    • Galv says:

      When testing/playing your game, you will need to start a new game (do not load a save file that was saved prior to adding the script).
      If that doesn’t solve your problem, please let me know when the error occurs. For example, after transferring a map? Or as soon as you start a new game?

      • I like your quick reply, but, as you have suggested, I have started a new game, and even deleted the old save, and it’s still not working. I had been using these cam events and they worked perfectly until I reached to a certain a map with just two events (none of them moving) and then that error just comes up.

      • Galv says:

        Did you use the cam script on the map before it? I’m checking out a possible cross-map bug now

      • For some reason, your new comment is not letting me reply, so I’m gonna reply here. :)

        Yes, before that map, I actually use the cam-script on the map before it… About…Eight times. The ninth time is that I go back to the previous map(with switches that turns off the first cam event) and then transfer to another new map, and then that’s when the error pops up.

      • Galv says:

        I’m getting that no-reply-button thing, too. I thought it was odd.

        Anyway, what I suspect is happening is that you transfer to a new map while the camera is targeting an event ID that map doesn’t have, so it crashes. I have updated to v.1.4 with code that resets the camera target when you change maps so this wont be a problem. Let me know if this fixes the issue

      • :) Thank you! It works brilliantly well!

  7. Hi! It’s me again and I’ve been putting your script to good use, and I have encountered another little error. Sort of hard to explain, so I’m going to show you the image of my autorun event and a short video of the results of that event:
    Image —>
    video –>
    I really do like this script of yours. No more counting how many times I have to scroll the map. :) please fix, or tell what I did wrong in this autorun event!

    • Galv says:

      Woah funky haha
      My first thought is that it hasn’t finished it’s move to event when you tell it to return the player position… so it’s trying to do both at the same time. If you can try to check that and add more wait between them that would be good. If that’s not what’s happening, I’ll try to replicate it when I have some time

  8. Galv says:

    I tried to replicate this by creating a similar setup to your video but cannot get it to happen or see why it is happening. I think next step is if I can get hold of your project to try to work it out from there.

    • Hi, sorry for not replying. I just did the scroll map thing, but then used the cam_follow at the end. Sorry~
      If I encounter another one like it again, I’ll make sure to contact you. Besides, if it’s not happening to you, then it’s probably my mess up.

  9. xxrazex says:

    Hi Galv! I run into a similar problem with Carson and I’m not too sure
    why it happened. (The second problem he had)
    Here’s a screenshot of my event page:
    I need this script of yours so I hope you can help me.

    • Galv says:

      If you don’t mind sending my your project or something so I could have a look to try to find out why it’s happening that would be cool. If so, PM me on or

  10. Galv says:

    Cam control bug was found to be when using non-default screen sizes. I’ll have to find some time to fix it in future

  11. LynX says:

    Helo Galv, firstly thank You for this great script its nice :) but I have one problem with it! Im using Saphire Battle ssytem and and as You know there is a pixel movement and I got problem while using Your script. I use cam_follow(18, 4) and then message and then cam_center(4) and when camera go back its start to shake and its never stops… any way to repair it ?

  12. Einar. says:

    I have a suggestion for improving this script.

    When I was experimenting with your script, I noticed that the “cam_set(X,Y)” command always waits for the scroll to finish, before moving on to the next command. This makes doing stuff like having a narration text pop up, while you’re panning across landscapes or similar effects.

    Is it possible to add a functionality where you can opt out to wait for the the scroll to finish, before jumping to the next command, kinda like with the “Wait for completion” checkbox on the Move Route command?

  13. Is there a blocking problem or have you removed the Esc menu, as the demo does not seem to have a means to exit without closing the window via the X

  14. rvc27 says:

    can you made plugin for rpg maker mv, based on this sript?

  15. Saturn says:

    Hey, Galv!

    I am aware this script is pretty old (and that there is a replacement to it), but is it possible to lock the camera only in one axis?

    I’m using it to center a map in the X axis, but I want the camera to keep following the player on the Y axis. I tried making a parallel process event with the script call cam_set(10,$game_player.y,4), which works fine, but has a weird little delay (which is precisely why I don’t use the sliding script – I do not want that delay). If there was a way to increase the camera speed by decimals (or lock only one axis), I reckon it would solve the issue.

    I’ve been scratching my head with that for ages, so I decided to reach out! I’m so sorry to bother you on such an old script. hahah

    Thank you for the attention!

Leave a Reply to rvc27 Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s