Help with player movement

ayewyn

Warper
Member
Joined
Jun 27, 2015
Messages
4
Reaction score
0
Primarily Uses
I am trying to get a specific look to the movement in my game. I want players and NPCs to move from tile to tile without sliding between them like normal.





I couldn't find anything on how to change characters or NPCs sliding between tiles, so as a work around I decided to speed up movement so that it appears to have no time between tiles, then wait a moment before the next step. I made a little plug in with these values:

Game_CharacterBase.prototype.setMoveSpeed = function(moveSpeed) {this._moveSpeed = 9};


Game_CharacterBase.prototype.setMoveFrequency = function(moveFrequency) {this._moveFrequency = 2};

It got the desired effect for the NPCs and they look just like I intended, but it didn't effect the player at all. I can't seem to find what I need to change the player's movement. I can use an event on the map to change the player's speed, but nothing seems to pause the player between steps. So the player would just zip around the map.


Can anyone point me in the right direction as to what I need to be modifying for the player's movement in a plugin, or ideally what controls the slide between tiles?
 

MinusGix

MinusGix
Member
Joined
Jun 4, 2014
Messages
12
Reaction score
0
Primarily Uses
Could modify the function that moves the player and have it just set the x,y of the player instead?
 

ayewyn

Warper
Member
Joined
Jun 27, 2015
Messages
4
Reaction score
0
Primarily Uses
Could modify the function that moves the player and have it just set the x,y of the player instead?
Isn't it already kind of setting the x,y and just playing an animation and scrolling the map to get you there? I'm not sure where that is handled.
 

MinusGix

MinusGix
Member
Joined
Jun 4, 2014
Messages
12
Reaction score
0
Primarily Uses
I found this  


$gamePlayer._x = xval;
$gamePlayer._realX = xval;
$gamePlayer._y = yval;
$gamePlayer._realY = yval;


You have to set both. The game probably whenever the screen updates checks to see if they are different and if they are move the player slowly to that position, but if you set both of them to the same value right after each other then it will just snap the player to that position.
 

ayewyn

Warper
Member
Joined
Jun 27, 2015
Messages
4
Reaction score
0
Primarily Uses
I found this  



$gamePlayer._x = xval;
$gamePlayer._realX = xval;
$gamePlayer._y = yval;
$gamePlayer._realY = yval;


You have to set both. The game probably whenever the screen updates checks to see if they are different and if they are move the player slowly to that position, but if you set both of them to the same value right after each other then it will just snap the player to that position.
Thanks for your help so far. Where did you find that? I'm guessing that only works for the player, since it says Player, and there would be a separate version for autonomous movement events (NPCs). If possible I'd like them both to work the same way.
 

MinusGix

MinusGix
Member
Joined
Jun 4, 2014
Messages
12
Reaction score
0
Primarily Uses
I found it by looking at $gamePlayer and experimenting in the dev console.  


You can do the same thing with events by doing


$gameMap.event(eventId)._y = yval;
$gameMap.event(eventId)._realY = yval;
$gameMap.event(eventId)._x = xval;
$gameMap.event(eventId)._realX = xval;


You can find the eventId by clicking on them in rpgmaker. If you want to find the id in the program (like lets say using a script command in the event) you can do:


$gameMap.event(eventId)._y = yval;
$gameMap.event(eventId)._realY = yval;
$gameMap.event(eventId)._x = xval;
$gameMap.event(eventId)._realX = xval;

Code:
this._eventId // the eventId
you could do -
$gameMap.event(this._eventId)._y = yval;
$gameMap.event(this._eventId)._realY = yval;
$gameMap.event(this._eventId)._x = xval;
$gameMap.event(this._eventId)._realX = xval;
 

ayewyn

Warper
Member
Joined
Jun 27, 2015
Messages
4
Reaction score
0
Primarily Uses
I think I change the Game_CharacterBase to behave this way and have it work for the player and all the moving events.


I'm looking at this section:

Game_CharacterBase.prototype.moveStraight = function(d) {
    this.setMovementSuccess(this.canPass(this._x, this._y, d));
    if (this.isMovementSucceeded()) {
        this.setDirection(d);
        this._x = $gameMap.roundXWithDirection(this._x, d);
        this._y = $gameMap.roundYWithDirection(this._y, d);
        this._realX = $gameMap.xWithDirection(this._x, this.reverseDir(d));
        this._realY = $gameMap.yWithDirection(this._y, this.reverseDir(d));
        this.increaseSteps();
    } else {
        this.setDirection(d);
        this.checkEventTriggerTouchFront(d);
    }
};

I can't quite figure out the right way to change it though. A few of the ways I poked it caused the characters to jump 2 tiles, then slide backwards one. Which is close to what I want I guess. Maybe I am missing something obvious.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,038
Messages
1,018,466
Members
137,821
Latest member
Capterson
Top