Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Disable/Enable Player Movement

Minitut: Quick Player Movement
Author: Meâ„¢
Version: 1.0


This Mini-Tutorial was created as I have read quite some general support threads about: How can I stop the player from moving? Now, In RMXP there is a so super simple command for it.

Disable the movement
Instead of blocking the player in, setting his face lock on and putting him on an impassable tile, you can simply use the event code below. Hé! What happens? The player moves towards... himself. Yes, that is impossible. The player will be blocked (movement) until it is enabled.
Code:
@>[color=darkred]Set Move Route: Player[/color]
:               [color=darkred]: $>Move toward Player[/color]


Enable the movement
To (re)-enable the players movement, you can simply use the event code below. This will unblock (movement) him, until you block it again...
Code:
@>[color=darkred]Set Move Route: Player[/color]
:               [color=darkred]: $>Turn away from Player[/color]


Meâ„¢
 
@psgels: I agree a FAQ is better for this.

Scripts work so much easier Me...

Note that this requires the SDK (just part of an old script) (I can make one non-SDK).
Code:
#==============================================================================
# ** Game_Player
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :disable_player_movement
  attr_accessor :disable_player_trigger
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_ispsystem_gameplayer_init initialize
  alias seph_ispsystem_gameplayer_upm update_player_movement
  alias seph_ispsystem_gameplayer_uat update_action_trigger
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Turns Off Disable Movement & Trigger
    @disable_player_movement = false
    @disable_player_trigger = false
    # Original Initialization
    seph_ispsystem_gameplayer_init
  end
  #--------------------------------------------------------------------------
  # * Player Movement Update
  #--------------------------------------------------------------------------
  def update_player_movement
    # Original Update Player Movement Unless Movement Disabled
    seph_ispsystem_gameplayer_upm unless @disable_player_movement
  end
  #--------------------------------------------------------------------------
  # * Update Action Trigger
  #--------------------------------------------------------------------------
  def update_action_trigger
    # Original Update Player AT Unless Movement Disabled
    seph_ispsystem_gameplayer_uat unless @disable_player_trigger
  end
end

Now you can just use $game_player.disable_player_movement = true or false and it will disable movement.
 
Both ways work fine. This is interesting indeed. :3

Although I might see myself using the Move Event thing more, but the Script thing seems easy as well.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top