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.

Disappearing act in 8dir?

So I modified a small part in the scripts:
class Game_Player < Game_Character
  def move_by_input
    return unless movable?
    return if $game_map.interpreter.running?
    case Input.dir8
    when 1;  move_lower_left
    when 2;  move_down
    when 3;  move_lower_right
    when 4;  move_left
    when 6;  move_right
    when 7;  move_upper_left
    when 8;  move_up
    when 9;  move_upper_right
    end
  end
end

Now this works, from what I can see, almost perfectly. The weird part is if your walking diagonally(specifically up and left or right), sometimes you stop controlling the character, the character disappears, and you start controlling the camera. After awhile, the character will reappear, in the spot they were in, but the camera's wrong. I've only noticed this on a big map with loop. Does anyone know whats going on?
 
My best guess is one of your move_direction methods are changing the @direction instance to be something other than 2, 4, 6, 8, causing the Sprite_Character to incorrectly set the rect.

Do a search for "@direction = " in all the classes. Check to make sure the number after = is not different than 2, 4, 6, 8
 
I found the problem. It looks like a shortcut Enterbrain used because they didn't think someone would just change a bit of text:

  #--------------------------------------------------------------------------
  # * Move Lower Left
  #--------------------------------------------------------------------------
  def move_lower_left
    unless @direction_fix
      @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction) ## <<<< Also, I just changed this to my liking. It also allowed for bad directions
    end
    if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
       (passable?(@x-1, @y) and passable?(@x-1, @y+1))
      @x -= 1         ######                                        <<<<<< note they only changed @x, not @real_x
      @y += 1
      increase_steps
      @move_failed = false
    else
      @move_failed = true
    end
  end
So here is the updated 8dir script, but I'll update it if I find/hear of bugs:
begin
class Game_Character
  #--------------------------------------------------------------------------
  # * Move Lower Left
  #--------------------------------------------------------------------------
  def move_lower_left
    unless @direction_fix
      @direction = (2)
    end
    if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
       (passable?(@x-1, @y) and passable?(@x-1, @y+1))
      @x = $game_map.round_x(@x-1)
      @real_x = (@x+1)*256
      @y = $game_map.round_y(@y+1)
      @real_y = (@y-1)*256
      increase_steps
      @move_failed = false
    else
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # * Move Lower Right
  #--------------------------------------------------------------------------
  def move_lower_right
    unless @direction_fix
      @direction = (6)
    end
    if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
       (passable?(@x+1, @y) and passable?(@x+1, @y+1))
      @x = $game_map.round_x(@x+1)
      @real_x = (@x-1)*256
      @y = $game_map.round_y(@y+1)
      @real_y = (@y-1)*256
      increase_steps
      @move_failed = false
    else
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Left
  #--------------------------------------------------------------------------
  def move_upper_left
    unless @direction_fix
      @direction = (4)
    end
    if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
       (passable?(@x-1, @y) and passable?(@x-1, @y-1))
      @x = $game_map.round_x(@x-1)
      @real_x = (@x+1)*256
      @y = $game_map.round_y(@y-1)
      @real_y = (@y+1)*256
      increase_steps
      @move_failed = false
    else
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Right
  #--------------------------------------------------------------------------
  def move_upper_right
    unless @direction_fix
      @direction = (8)
    end
    if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
       (passable?(@x+1, @y) and passable?(@x+1, @y-1))
      @x = $game_map.round_x(@x+1)
      @real_x = (@x-1)*256
      @y = $game_map.round_y(@y-1)
      @real_y = (@y+1)*256
      increase_steps
      @move_failed = false
    else
      @move_failed = true
    end
  end
end

class Game_Player < Game_Character
  def move_by_input
    return unless movable?
    return if $game_map.interpreter.running?
    case Input.dir8
      when 1;  move_lower_left
      when 2;  move_down
      when 3;  move_lower_right
      when 4;  move_left
      when 6;  move_right
      when 7;  move_upper_left
      when 8;  move_up
      when 9;  move_upper_right
    end
  end
end
end

I honestly thought this task would be alot harder...

Thank you SepherothSpawn. Another one of those things I never woulda thought of.
 
      @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)


There is no error there. It's saying if you are facing right, turn left. If you are facing up, turn down. If you are facing left or down, it won't change the direction at all.

Do not touch @real_x or @real_y. That is a movement detection and screen position. Modify this is just bad. Don't do it!

What is the point of @move_failed? As long as you aren't screwing up the @real_x and @real_y, you can just use the method "moving?" The moving? method uses the last @real_x/@real_y and compares it to what it should be based off the @x/@y instances.


* scratches head *
 
well... I just copied this out of Game_character and modified the x/y stuff and direction stuff. I noticed RealX/Y was modified when you move normally, but not diagonally, so I added it in.

I think the @direction thing is what was being screwy, because it assumed you could only face 4 directions.

Should I change anything around?
 
The @real instances are changed when you move normal (at least not the move_dir methods). They are only used in the update processing.

Well yes, by default only 4 directions because of the interaction with Sprite_Character. The only way you should change @direction != 2, 4, 6, 8 is if you did some modification in Sprite_Character.

I would change the @real first off. Excess code that is only going to hurt you eventually. @direction is not a big deal if you are setting it to be 2, 4, 6, 8.
 
well, i tried just having diagonal movement be the same, except setting a direction. It looks like change real_x/y is what stops the disappearing act. I don't understand it...

The only script changes I have is this script and the Tankentai battle system, so I don't know what would be affecting things...
 

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