RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[xp] Diagonal Movement Speed Too Fast

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 81
I'm using an 8 directional pixel movement script and it works great but the only problem is that the diagonal movement speed is too fast because when you move diagonally you're essentially moving two directions (down+left, up+right, etc) in the same time.  Is there anyway to adjust individual direction's movement speed?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
What is the diagonal movement script you're using?

**
Rep: +0/-0Level 81
What is the diagonal movement script you're using?

f0tz!bearchan's 1.6 script

http://www.mediafire.com/?diymdgjhynn

I really don't know much about scripts.  Is there anyway to edit the distance/time of the diagonal movements?  Since it's traveling diagonally across the hypotenuse (the longest side of the two right triangles that form the square) it goes to fast since it's essentially covering more distance in the same time, if that makes any sense

**
Rep: +0/-0Level 81
I managed to get the movement speed worked out by changing the script from

Spoiler for:
  #-----------------------------------------------------------------------------
  # move_lower_left, more pixellike
  #-----------------------------------------------------------------------------
  def move_lower_left (steps = 32, turn_enabled = true)
    self.turn_lower_left if turn_enabled
   
    # passable?
    if passable?(@x, @y, 1, steps)
      @x -= @max_steps
      @y += @max_steps
      increase_steps
    else
     
      # checks for event activation
      check_event_trigger_touch(@x - @max_steps, @y + @max_steps)
     
      # not passable but the character can walk (@maxsteps > 0)
      if (@max_steps > 0 and @max_steps < steps)
        @x -= @max_steps
        @y += @max_steps
        increase_steps
      end
     
    end
  end

to

Spoiler for:
  #-----------------------------------------------------------------------------
  # move_lower_left, more pixellike
  #-----------------------------------------------------------------------------
  def move_lower_left (steps = 32, turn_enabled = true)
    self.turn_lower_left if turn_enabled
   
    # passable?
    if passable?(@x, @y, 1, steps)
      @x -= 1
      @y += 1
      increase_steps
    else
     
      # checks for event activation
      check_event_trigger_touch(@x - @max_steps, @y + @max_steps)
     
      # not passable but the character can walk (@maxsteps > 0)
      if (@max_steps > 0 and @max_steps < steps)
        @x -= @max_steps
        @y += @max_steps
        increase_steps
      end
     
    end
  end

I did this for all of the diagonal movements and then for the up,down,left, and right movements i changed the x and y steps to 1.4 (to account for the hypotenuse).

This solves the speed problem but now whenever I go to the edge of the screen I get this error:

"Script 'game_character' line 1064: typeerror occured.  cannot iterate from Float"

Here's the line of code with line 1064 being underlined
Spoiler for:
  #-----------------------------------------------------------------------------
  # Passable? method
  # has been rebuilt for both collision maps and databse passability
  #-----------------------------------------------------------------------------
  def passable?(x, y, d = 0, self_event = nil) 
   
    # returns if coords are not on the map
    return false if not valid?(x, y)
   
    # if d is not 2, 4, 6 or 8
    case d
    when 0
      return true
    when 1
      return (passable?(x, y, 2, self_event) and passable?(x, y, 4, self_event))
    when 3
      return (passable?(x, y, 2, self_event) and passable?(x, y, 6, self_event))
    when 7
      return (passable?(x, y, 8, self_event) and passable?(x, y, 4, self_event))
    when 9
      return (passable?(x, y, 8, self_event) and passable?(x, y, 6, self_event))
    else
      return false if not [2, 4, 6, 8].include?(d)
    end
                   
    # loads size
    if self_event == nil
      x_size = y_size = 2
    else
      x_size = [self_event.size['x'], 2].max
      y_size = [self_event.size['y'], 2].max
    end
   
    # checks pixel on collision map / in the database
    counter = 0
       
    case d
    when 2
      fix = y - 1
      for i in (x - x_size / 2)..(x + x_size / 2 - 1)
        counter += 1 if i%2 == 0 and self.pixel_passable?(i, fix, d, self_event)
      end
      return counter >= x_size / 2
     
    when 4
      fix = (x - x_size / 2)
      for i in (y - y_size - 1)..(y - 1)
        counter += 1 if i%2 == 0 and self.pixel_passable?(fix, i, d, self_event)
      end
      return counter >= y_size / 2
     
    when 6
      fix = (x + x_size / 2 - 1)
      for i in (y - y_size - 1)..(y - 1)
        counter += 1 if i%2 == 0 and self.pixel_passable?(fix, i, d, self_event)
      end
      return counter >= y_size / 2
     
    when 8
      fix = (y - y_size - 1)
      for i in (x - x_size / 2)..(x + x_size / 2 - 1)
        counter += 1 if i%2 == 0 and self.pixel_passable?(i, fix, d, self_event)
      end
      return counter >= x_size / 2
    end
       

So i'm assuming that by changing the x and y modifiers I made this part of the script that deals with passability incompatible.  I would assume that i would only have to change some of the numbers to fix this but i'm not sure since i suck at scripts