Disable player turning up or down?

Discussion in 'RPG Maker MV' started by Jogabba, Oct 4, 2016.

  1. Jogabba

    Jogabba Villager Member

    Messages:
    27
    Likes Received:
    14
    First Language:
    Spanish
    Hi! I was wondering if there's any way to prevent the player to turn into certain directions. For example, I want to disable the Up and Down arrows in a certain map, allowing the player only to face/move left and right.


    Remember that I'm not asking only to restrict movement in certain directions, but specially to avoid the player face these directions when the movement key is pressed.


    Any ideas?
     
    #1
  2. Waterguy

    Waterguy Veteran Veteran

    Messages:
    1,168
    Likes Received:
    251
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    You could fix the direction and when the player presses up or down (checked through conditional branches) they either quickly unlock, turn around and lock again, or move a step forward if they were already looking in that direction?
     
    #2
  3. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,568
    Likes Received:
    1,323
    Location:
    Canada / Québec
    First Language:
    French
    Primarily Uses:
    RMMV


    Game_Map.prototype.doScroll = function(direction, distance) {
        switch (direction) {
        case 2:
            this.scrollDown(distance);
            break;
        case 4:
            this.scrollLeft(distance);
            break;
        case 6:
            this.scrollRight(distance);
            break;
        case 8:
            this.scrollUp(distance);
            break;
        }
    };


    and for multi condition map or switch

    Code:
    if ($gameMap._mapId==7 && $gameSwitches.value(15) == false)
     
    #3
    The Stranger likes this.
  4. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,053
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    I'm not sure what the above is for.  Those scripts have nothing to do with either the player's direction or movement.


    You'd have to not only stop keyboard input in the up/down directions on that map, but also cater for mouse clicks that might cause the player to move up/down.  Would you just disable mouse movement on that map, or allow it, but only process left/right instructions?
     
    Last edited by a moderator: Oct 4, 2016
    #4
  5. Dad3353

    Dad3353 Veteran Veteran

    Messages:
    421
    Likes Received:
    108
    Location:
    France
    First Language:
    English
    Would it be feasible to limit movement on the relevant Tiles, and create a Character set for the Hero with only Right and Left sprites (copy Right to Up, Left to Down, for instance...). Switch sprites when in this situation; the Hero will always face Right or Left, and be unable to move Up or Down. Switch back to the normal sprite, of course once this is over. Any mileage..?
     
    #5
  6. Wookiee420

    Wookiee420 Veteran Veteran

    Messages:
    294
    Likes Received:
    131
    Location:
    Colorado
    First Language:
    English
    could you do this even easier? If i read this correctly what you want to do is still have up and down key work but not change the direction your are facing, silly example would be a side scrolling shooter or something like that.


    what about just having a sprite sheet without the actor facing those directions (essentially have it be two rows of right and two rows of left), and have the start/stop of the section be a simple event that switches the actors sprite?
     
    #6
  7. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,568
    Likes Received:
    1,323
    Location:
    Canada / Québec
    First Language:
    French
    Primarily Uses:
    RMMV
  8. Jogabba

    Jogabba Villager Member

    Messages:
    27
    Likes Received:
    14
    First Language:
    Spanish
    Hi, thank you all for your answers!


    I fixed the problem with an event that checks if the player has pressed the up/down buttons and making the character turn towards the player if that's the case. The character IS the player, so the sprite doesn't move at all, which is the desired behaviour.


    This does not work with mouse clicks, tho. Not really a big problem for me, as I was planning to disable mouse control for this game.
     
    Last edited by a moderator: Oct 4, 2016
    #8
  9. Waterguy

    Waterguy Veteran Veteran

    Messages:
    1,168
    Likes Received:
    251
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    That 2d Fixed Direction would be a good one... if it wasn't forced to be there the entire game...
     
    #9

Share This Page