Hi, I was just wondering this is possible or if there's a code for it somewhere. Basically I wanna make a character/object goes off the map and loops back from the other side of the same map WITHOUT using scroll type loop map? Hope it doesn't sound confusing or anything > <
Is it possible for character/object goes off map & loops back from the other side without using loop map?
RPG Maker VXAce SupportYou can cheat and put in something like
if (this.x==0){this.locate( OTHERSIDEOFMAP,this.y)
into your moveroute
if (this.x==0){this.locate( OTHERSIDEOFMAP,this.y)
into your moveroute
@Restart that code is using JavaScript syntax and is definitely not going to work in VX Ace.
However, doing that is definitely possible. I do not remember if it is the same when using custom movement, but you could simply have a parallel process event run every N frames (N is any number that fits your need) that simply moves the object to the other side of the screen once it reaches either side of the map.
However, doing that is definitely possible. I do not remember if it is the same when using custom movement, but you could simply have a parallel process event run every N frames (N is any number that fits your need) that simply moves the object to the other side of the screen once it reaches either side of the map.
Code:
event = $game_map.events[your_event_id_goes_here]
if (event.x == 0)
event.moveto($game_map.width - 1, event.y)
elsif (event.x == $game_map.width - 1)
event.moveto(0, event.y)
end
# Similarly for the Y coordinate
yeah I just meant something like that, obvs not that exact code
Thank you for the help, though I'm a little confuse by this cause I'm not sure how to do that. Is it possible if you provide some kind of demonstration or where I should input these? ;;
If it's eventing wise for a scene, can't you just "Teleport" or "Move" the object there after they walk towards the edge to give the illusion?
This one I have is a type of vehicle that takes up 6 tiles for a size, wouldn't it look strange when it suddenly disappear and ''pops up'' from the other side? I rather for it to move smoothly off the map and on the other side of the map. :<
Here is a screenshot of my event. I recommend using a
Feel free to disable the "Walking Animation" option as well, the event does not need it.
move_straight line inside the event itself to move your event from the parallel process itself. It ensures that the parallel process only checks the event position once the movement ends and also make your movement smoother.Feel free to disable the "Walking Animation" option as well, the event does not need it.
You don't need a parallel process or fiber.yield for this. Just do a Custom Move Route that has:
Or if it's moving right:
However, a character that takes up 6 tiles is not going to move smoothly off or on the map. If it's a single event with a large sprite, when the event (which is the middle of the sprite) hits the edge, the whole thing will disappear and reappear on the other side.
Code:
Move Left
Script: @x = $game_map.width - 1 if @x == 0
Or if it's moving right:
Code:
Move Right
Script: @x = 0 if @x == $game_map.width - 1
However, a character that takes up 6 tiles is not going to move smoothly off or on the map. If it's a single event with a large sprite, when the event (which is the middle of the sprite) hits the edge, the whole thing will disappear and reappear on the other side.
I got this error, I'm unsure what it means...
I tried yours, though it moves back and forth instead and didn't go off the map. :0
It means that you used
$game_map.width -1 instead of $game_map.width - 1. If you put a space before the minus sign and put no space after it, the inerpreter reads it as $game_map.width and then -1 as a negative number.@Shaz doing that in a custom move route is very buggy. Since the X coordinate reaches 0 before the movement ends and your character is still moving (defined as
@real_x != @x), instead of having the event teleport to the other side you simply have a sliding sprite that goes in the opposite direction. You have to use moveto($game_map.width - 1, @y) instead.EDIT: the op ninjed me.
Can you show a screenshot of your event please?
Oh, it worked nicely! Thank you so much! Is not exactly perfect cause I made a type of vehicle that takes up to 6 tiles and because is set as a character moving on its own, it shows up a bit weird from the other side but is no big deal if something like this can't be fixed. ^^;;;
@XENVITA there are ways to fix that, one of those is to display it as a sprite rather than a vehicle, this way you can move it outside of the map without any constraint imposed by the Character class. However, I am not sure what you are going to do with that so I cannot tell whether or not it is a good idea.
I actually didn't make it as a vehicle, I turned it as a [!$] character sprite cause the size of the vehicle is 6 tiles graphic. It just that it kinda register it's middle tile as the character on something you can interact.
It was a bad choice of words on my end, I apologize. What I meant is that anything that belongs to the Game_Character class, and events belong to that class as well, can only move withing the boundaries of the map. Depending on how you are using it, you might or might not use a simple sprite (or a picture) instead of an event. It is more complicated and requires a bit of planning, but it can be done and also ensures a smooth movement and an equally smooth transition from one part of the map to the other.
However, before telling you how to do it, I would like to know how you are going to use it. It might not be worth the effort.
However, before telling you how to do it, I would like to know how you are going to use it. It might not be worth the effort.
For another workaround option, you can just put a border of empty tiles around the edge of your usable map, and use a camera script to make sure the player never sees it.
I was thinking of the same thing, with maybe an over character tile that looks like empty screen.
Hey
You can try this script
It allow the use of the loop function without the camera loop
You just have to copy this lines to a script call in an event.
It works well on a parallel event that you delete right after.
these commands automatically "center" the camera on the player.
Last edit : 19/04/20
You can try this script
It allow the use of the loop function without the camera loop
You just have to copy this lines to a script call in an event.
It works well on a parallel event that you delete right after.
Ruby:
lock_horizontal_loop
lock_vertical_loop
unlock_horizontal_loop
unlock_vertical_loop
these commands automatically "center" the camera on the player.
Ruby:
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias_method :initialize_before_loop, :initialize
def initialize
initialize_before_loop
@display_loop_h = true
@display_loop_v = true
end
#--------------------------------------------------------------------------
# * Loop horizontally ?
#--------------------------------------------------------------------------
def display_loop_horizontal?
loop_horizontal? && @display_loop_h
end
#--------------------------------------------------------------------------
# * Loop vertically ?
#--------------------------------------------------------------------------
def display_loop_vertical?
loop_vertical? && @display_loop_v
end
#--------------------------------------------------------------------------
# * Center screen
#--------------------------------------------------------------------------
def center_screen
$game_player.center($game_player.x, $game_player.y)
end
#--------------------------------------------------------------------------
# * Lock / Unlock display loops
#--------------------------------------------------------------------------
def lock_horizontal_loop; @display_loop_h = false; center_screen; end
def lock_vertical_loop; @display_loop_v = false; center_screen; end
def unlock_horizontal_loop; @display_loop_h = true; center_screen; end
def unlock_vertical_loop; @display_loop_v = true; center_screen; end
#--------------------------------------------------------------------------
# * Calculate X Coordinate, Minus Display Coordinate
#--------------------------------------------------------------------------
def adjust_x(x)
if display_loop_horizontal? && x < @display_x - (width - screen_tile_x) / 2
x - @display_x + @map.width
else
x - @display_x
end
end
#--------------------------------------------------------------------------
# * Calculate Y Coordinate, Minus Display Coordinate
#--------------------------------------------------------------------------
def adjust_y(y)
if display_loop_vertical? && y < @display_y - (height - screen_tile_y) / 2
y - @display_y + @map.height
else
y - @display_y
end
end
#--------------------------------------------------------------------------
# * Set Display Position
#--------------------------------------------------------------------------
def set_display_pos(x, y)
x = [0, [x, width - screen_tile_x].min].max unless display_loop_horizontal?
y = [0, [y, height - screen_tile_y].min].max unless display_loop_vertical?
@display_x = (x + width) % width
@display_y = (y + height) % height
@parallax_x = x
@parallax_y = y
end
#--------------------------------------------------------------------------
# * Scroll Down
#--------------------------------------------------------------------------
def scroll_down(distance)
if display_loop_vertical?
@display_y += distance
@display_y %= @map.height
@parallax_y += distance if @parallax_loop_y
else
last_y = @display_y
@display_y = [@display_y + distance, height - screen_tile_y].min
@parallax_y += @display_y - last_y
end
end
#--------------------------------------------------------------------------
# * Scroll Left
#--------------------------------------------------------------------------
def scroll_left(distance)
if display_loop_horizontal?
@display_x += @map.width - distance
@display_x %= @map.width
@parallax_x -= distance if @parallax_loop_x
else
last_x = @display_x
@display_x = [@display_x - distance, 0].max
@parallax_x += @display_x - last_x
end
end
#--------------------------------------------------------------------------
# * Scroll Right
#--------------------------------------------------------------------------
def scroll_right(distance)
if display_loop_horizontal?
@display_x += distance
@display_x %= @map.width
@parallax_x += distance if @parallax_loop_x
else
last_x = @display_x
@display_x = [@display_x + distance, (width - screen_tile_x)].min
@parallax_x += @display_x - last_x
end
end
#--------------------------------------------------------------------------
# * Scroll Up
#--------------------------------------------------------------------------
def scroll_up(distance)
if display_loop_vertical?
@display_y += @map.height - distance
@display_y %= @map.height
@parallax_y -= distance if @parallax_loop_y
else
last_y = @display_y
@display_y = [@display_y - distance, 0].max
@parallax_y += @display_y - last_y
end
end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# - command_354
# Return to title now return to profile screen
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# * Lock / Unlock display loops
#--------------------------------------------------------------------------
def lock_horizontal_loop; $game_map.lock_horizontal_loop; end
def lock_vertical_loop; $game_map.lock_vertical_loop; end
def unlock_horizontal_loop; $game_map.unlock_horizontal_loop; end
def unlock_vertical_loop; $game_map.unlock_vertical_loop; end
end
Original thread: https://forums.rpgmakerweb.com/threads/is-it-possible-for-character-object-goes-off-map-loops-back-from-the-other-side-without-using-loop-map.120360/