How do I increase a sprite's animation speed without changing their walking speed?

KateMarie999

Villager
Member
Joined
Mar 3, 2017
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMVXA
Hey there, I'm looking to change the frames it takes between each frame of animation from each sprite without changing the walking speed. A pattern delay, in RGSS3, I think.

I managed this in my Ace project, but have failed to figure it out in my MV project. I've been all over the place and I've yet to find a single thread that even mentions it other than this: https://forums.rpgmakerweb.com/index.php?threads/dashing-anime-different-from-walking.46445/ and it's not quite what I'm asking. I don't want the characters' walking speeds to increase, just the animation.

I'm hoping to be pointed in the direction of a plugin or maybe told how to do this myself, because it's driving me nuts. How can I set it at will?

Here's my setup in VX Ace. I had this script:
1591484951430.png
And then in the events/move routes I wanted to adjust, I did this:
1591484892796.png

I'd really appreciate your help with this because I've been setting everything to the fastest speed and highest frequency and it moves incredibly slow. MV's animation speeds are slower than Ace's already, but it's absurd how slow it is.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,653
Reaction score
1,105
First Language
EN
Primarily Uses
RMMV
:kaohi: Check out this thread, sounds like the same question~
 

KateMarie999

Villager
Member
Joined
Mar 3, 2017
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMVXA
Yeah, I was actually about to ask about it; I managed to do it for the whole game, but I want to do it by character, since the number of animation frames vary.
1591487529966.png
This worked temporarily, but restarting the game reset it. I'm looking to do it permanently but only by event, and to set the player character back when that section is over, since his sprite changes. I'm not exactly a js expert so I don't know how to format it so it works per event.
 

KateMarie999

Villager
Member
Joined
Mar 3, 2017
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMVXA
I started making a plugin, and I was able to set up the parameters for the walking and animation speed but hit a roadblock when the tutorial I was watching used an extremely simplistic example for plugin commands and didn't elaborate enough for me to understand exactly how they worked. And I've been going nuts trying to find another tutorial.
1591498374842.png
I hoped to put a plugin command into the move route, but I'm stuck.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,653
Reaction score
1,105
First Language
EN
Primarily Uses
RMMV
The QSprite plugin looks promising! :kaojoy:

Otherwise, if you want to continue making your own thing, some comments:
  • It's possible for two events to animate at the same time. Therefore if different events should animate at different rates, there can't be just a single anim value. Each character will need their own value.

  • Plugin commands can be used in events, but not inside move routes. Plugin commands are essentially (and, preferably, literally) nicely-formatted script calls. If you want to run some plugin-related function inside a move route, you'll need something that goes in a Script move command.

  • Calling an alias, e.g. _Game_CharacterBase_animationWait.call(this), yields the return value of the original method.

  • There are various approaches to setting a value here. Some ideas:
    1. Use a notetag in the event's Note box. This applies to all the event's pages but is relatively easy to do, since the engine automatically parses simple notetags in the Note box.

      As an example, let's say event ID 1 has this in its Note box: <tagName: value>. You can then use $gameMap.event(1).event().meta.tagName to return " value". Like plugin parameters, notetag values are always retrieved as strings a.k.a. text.

    2. Use a comment tag, i.e. a Comment command with a notetag in it. This applies on a per-page basis and requires checking each page's commands for relevant comments and parsing them appropriately. It's more flexible, but more complex to implement.

    3. Use a script call to set the value of a property on the event. This is the most flexible option, but requires some kind of "starting" trigger. Could do this with a Parallel event on applicable maps that ends with Erase Event (so it runs once per visit to the map). Another option is to stick the script call in a [non-repeating] move route on applicable events, but note that by default RMMV only processes up to one move route command per frame.
Could try something like this:
JavaScript:
// ==================================================
// KM_AnimRate.js
// ==================================================

/*:
 * @plugindesc v1.0 - change the animation rate of events using notetags.
 * @author Author
 * @help You can use this script in a move route to set the animation rate:
 *    this.setAnimationRate(1);
 * This will set the character's animation to 1 times the normal rate.
 * Each character will have their own animation rate.
 * For events, animation rates will persist until the player goes to another map.
 * 
 * @param Default Rate
 * @text Default Rate
 * @type number
 * @min 0
 * @max 100
 * @decimals 5
 * @desc Default multiplier for animation delay.
 * A lower number means faster animation. Default: 1.
 * @default 1
 */

var KM = KM || {};                      // Author namespace (globally-accessible stuff by author)
KM.AnimRate = KM.AnimRate || {};        // Plugin namespace (globally-accessible stuff for this plugin)

var Imported = Imported || {};          // Import namespace
Imported.KM_AnimRate = 1.0;             // Import declaration (version)

(function($) {      // In here, $ = KM.AnimRate (see last line of this plugin)

    // Some handy constants (only visible to this plugin because they're inside the IIFE)
    const PLUGIN_NAME = 'KM_AnimRate';
    const ERR_NOPARAM = 'Could not find parameters for plugin "' + PLUGIN_NAME + '".\nMake sure the plugin file is named correctly and try again.';

    $.params = PluginManager.parameters(PLUGIN_NAME);           // Fetch parameters via plugin name
    if (!$.params) throw new Error(ERR_NOPARAM);                // No params found? Stop and tell the user!

    $.dFault = Number($.params['Default Rate']);                // Convert string -> number

    // New method! Sets this character's animation rate multiplier.
    Game_CharacterBase.prototype.setAnimationRate = function(rate) {
        if (!isNaN(rate)) {                                     // is not "Not a Number", i.e. rate is a number
            rate = Number(rate);                                // convert strings, e.g. "1", to number
            if (rate === $.dFault) delete this._animationRate;  // don't need to store value if it's default now
            else this._animationRate = rate > 0 ? rate : 0;     // set negative rates as 0
            return true;
        }
        return false;
    };

    // New method! Returns a multiplier for the animationWait value.
    Game_CharacterBase.prototype.animationWaitMult = function() {
        if (this._animationRate !== undefined) {    // if this property exists on this character
            return this._animationRate;             // then return that value
        }
        return $.dFault;                            // else return default value
    };

    // Alias! Multiply the original animationWait value by this character's animationWaitMult.
    $.Game_CharacterBase_animationWait = Game_CharacterBase.prototype.animationWait;
    Game_CharacterBase.prototype.animationWait = function() {
        return $.Game_CharacterBase_animationWait.call(this) * this.animationWaitMult();
    };

})(KM.AnimRate);    // Pass plugin namespace in as first argument of IIFE
Here I'm using the "set value using script call" approach I described above (point 3), rather than note- or comment-tags. :)
 
Last edited:

KateMarie999

Villager
Member
Joined
Mar 3, 2017
Messages
11
Reaction score
1
First Language
English
Primarily Uses
RMVXA
The QSprite plugin looks promising! :kaojoy:

Otherwise, if you want to continue making your own thing, some comments:
  • It's possible for two events to animate at the same time. Therefore if different events should animate at different rates, there can't be just a single anim value. Each character will need their own value.

  • Plugin commands can be used in events, but not inside move routes. Plugin commands are essentially (and, preferably, literally) nicely-formatted script calls. If you want to run some plugin-related function inside a move route, you'll need something that goes in a Script move command.

  • Calling an alias, e.g. _Game_CharacterBase_animationWait.call(this), yields the return value of the original method.

  • There are various approaches to setting a value here. Some ideas:
    1. Use a notetag in the event's Note box. This applies to all the event's pages but is relatively easy to do, since the engine automatically parses simple notetags in the Note box.

      As an example, let's say event ID 1 has this in its Note box: <tagName: value>. You can then use $gameMap.event(1).event().meta.tagName to return " value". Like plugin parameters, notetag values are always retrieved as strings a.k.a. text.

    2. Use a comment tag, i.e. a Comment command with a notetag in it. This applies on a per-page basis and requires checking each page's commands for relevant comments and parsing them appropriately. It's more flexible, but more complex to implement.

    3. Use a script call to set the value of a property on the event. This is the most flexible option, but requires some kind of "starting" trigger. Could do this with a Parallel event on applicable maps that ends with Erase Event (so it runs once per visit to the map). Another option is to stick the script call in a [non-repeating] move route on applicable events, but note that by default RMMV only processes up to one move route command per frame.

Could try something like this:
JavaScript:
// ==================================================[/INDENT][/INDENT]
[INDENT][INDENT]// KM_AnimRate.js[/INDENT][/INDENT]
[INDENT][INDENT]// ==================================================[/INDENT][/INDENT]
[INDENT][INDENT][/INDENT][/INDENT]
[INDENT][INDENT]/*:[/INDENT][/INDENT]
[INDENT][INDENT]* @plugindesc v1.0 - change the animation rate of events using notetags.[/INDENT][/INDENT]
[INDENT][INDENT]* @author Author[/INDENT][/INDENT]
[INDENT][INDENT]* @help You can use this script in a move route to set the animation rate:[/INDENT][/INDENT]
[INDENT][INDENT]*    this.setAnimationRate(1);[/INDENT][/INDENT]
[INDENT][INDENT]* This will set the character's animation to 1 times the normal rate.[/INDENT][/INDENT]
[INDENT][INDENT]* Each character will have their own animation rate.[/INDENT][/INDENT]
[INDENT][INDENT]* For events, animation rates will persist until the player goes to another map.[/INDENT][/INDENT]
[INDENT][INDENT]*[/INDENT][/INDENT]
[INDENT][INDENT]* @param Default Rate[/INDENT][/INDENT]
[INDENT][INDENT]* @text Default Rate[/INDENT][/INDENT]
[INDENT][INDENT]* @type number[/INDENT][/INDENT]
[INDENT][INDENT]* @min 0[/INDENT][/INDENT]
[INDENT][INDENT]* @max 100[/INDENT][/INDENT]
[INDENT][INDENT]* @decimals 5[/INDENT][/INDENT]
[INDENT][INDENT]* @desc Default multiplier for animation delay.[/INDENT][/INDENT]
[INDENT][INDENT]* A lower number means faster animation. Default: 1.[/INDENT][/INDENT]
[INDENT][INDENT]* @default 1[/INDENT][/INDENT]
[INDENT][INDENT]*/[/INDENT][/INDENT]
[INDENT][INDENT][/INDENT][/INDENT]
[INDENT][INDENT]var KM = KM || {};                      // Author namespace (globally-accessible stuff by author)[/INDENT][/INDENT]
[INDENT][INDENT]KM.AnimRate = KM.AnimRate || {};        // Plugin namespace (globally-accessible stuff for this plugin)[/INDENT][/INDENT]
[INDENT][INDENT][/INDENT][/INDENT]
[INDENT][INDENT]var Imported = Imported || {};          // Import namespace[/INDENT][/INDENT]
[INDENT][INDENT]Imported.KM_AnimRate = 1.0;             // Import declaration (version)[/INDENT][/INDENT]
[INDENT][INDENT][/INDENT][/INDENT]
[INDENT][INDENT](function($) {      // In here, $ = KM.AnimRate (see last line of this plugin)[/INDENT][/INDENT]
[INDENT][INDENT][/INDENT][/INDENT]
[INDENT][INDENT]    // Some handy constants (only visible to this plugin because they're inside the IIFE)[/INDENT][/INDENT]
[INDENT][INDENT]    const PLUGIN_NAME = 'KM_AnimRate';[/INDENT][/INDENT]
[INDENT][INDENT]    const ERR_NOPARAM = 'Could not find parameters for plugin "' + PLUGIN_NAME + '".\nMake sure the plugin file is named correctly and try again.';[/INDENT][/INDENT]
[INDENT][INDENT][/INDENT][/INDENT]
[INDENT][INDENT]    $.params = PluginManager.parameters(PLUGIN_NAME);           // Fetch parameters via plugin name[/INDENT][/INDENT]
[INDENT][INDENT]    if (!$.params) throw new Error(ERR_NOPARAM);                // No params found? Stop and tell the user![/INDENT][/INDENT]
[INDENT][INDENT][/INDENT][/INDENT]
[INDENT][INDENT]    $.dFault = Number($.params['Default Rate']);                // Convert string -> number[/INDENT][/INDENT]
[INDENT][INDENT][/INDENT][/INDENT]
[INDENT][INDENT]    // New method! Sets this character's animation rate multiplier.[/INDENT][/INDENT]
[INDENT][INDENT]    Game_CharacterBase.prototype.setAnimationRate = function(rate) {[/INDENT][/INDENT]
[INDENT][INDENT]        if (!isNaN(rate)) {                                     // is not "Not a Number", i.e. rate is a number[/INDENT][/INDENT]
[INDENT][INDENT]            rate = Number(rate);                                // convert strings, e.g. "1", to number[/INDENT][/INDENT]
[INDENT][INDENT]            if (rate === $.dFault) delete this._animationRate;  // don't need to store value if it's default now[/INDENT][/INDENT]
[INDENT][INDENT]            else this._animationRate = rate > 0 ? rate : 0;     // set negative rates as 0[/INDENT][/INDENT]
[INDENT][INDENT]            return true;[/INDENT][/INDENT]
[INDENT][INDENT]        }[/INDENT][/INDENT]
[INDENT][INDENT]        return false;[/INDENT][/INDENT]
[INDENT][INDENT]    };[/INDENT][/INDENT]
[INDENT][INDENT][/INDENT][/INDENT]
[INDENT][INDENT]    // New method! Returns a multiplier for the animationWait value.[/INDENT][/INDENT]
[INDENT][INDENT]    Game_CharacterBase.prototype.animationWaitMult = function() {[/INDENT][/INDENT]
[INDENT][INDENT]        if (this._animationRate !== undefined) {    // if this property exists on this character[/INDENT][/INDENT]
[INDENT][INDENT]            return this._animationRate;             // then return that value[/INDENT][/INDENT]
[INDENT][INDENT]        }[/INDENT][/INDENT]
[INDENT][INDENT]        return $.dFault;                            // else return default value[/INDENT][/INDENT]
[INDENT][INDENT]    };[/INDENT][/INDENT]
[INDENT][INDENT][/INDENT][/INDENT]
[INDENT][INDENT]    // Alias! Multiply the original animationWait value by this character's animationWaitMult.[/INDENT][/INDENT]
[INDENT][INDENT]    $.Game_CharacterBase_animationWait = Game_CharacterBase.prototype.animationWait;[/INDENT][/INDENT]
[INDENT][INDENT]    Game_CharacterBase.prototype.animationWait = function() {[/INDENT][/INDENT]
[INDENT][INDENT]        return $.Game_CharacterBase_animationWait.call(this) * this.animationWaitMult();[/INDENT][/INDENT]
[INDENT][INDENT]    };[/INDENT][/INDENT]
[INDENT][INDENT][/INDENT][/INDENT]
[INDENT][INDENT]})(KM.AnimRate);    // Pass plugin namespace in as first argument of IIFE
Here I'm using the "set value using script call" approach I described above (point 3), rather than note- or comment-tags. :)
Thank you, this all helps a lot. I want to learn how to do a lot of this myself, but I'm not yet fluent in how coding works for any language, so I'm trying to learn how while also working on my game. Last night, I fiddled around with script calls and got it working by putting them in move routes:
Code:
$gameMap.event(9).animationWait = function (){return (9 - this.realMoveSpeed()) * 1.5;};
It was effective, though I had to go through the whole area of the game to change every event. I was shocked I'd even found a solution. I'll plug in your code and see how it works too.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,653
Reaction score
1,105
First Language
EN
Primarily Uses
RMMV
Thank you, this all helps a lot. I want to learn how to do a lot of this myself, but I'm not yet fluent in how coding works for any language, so I'm trying to learn how while also working on my game. Last night, I fiddled around with script calls and got it working by putting them in move routes:
Code:
$gameMap.event(9).animationWait = function (){return (9 - this.realMoveSpeed()) * 1.5;};
It was effective, though I had to go through the whole area of the game to change every event. I was shocked I'd even found a solution. I'll plug in your code and see how it works too.
Note that while your approach works temporarily, it only persists until you leave the map (not really a problem) and is not included in save files (potentially a problem). I.e. if you apply the override, save, close the game window, then launch the game and continue from that save, the character(s) will be back to animating at the default speed. :kaoback:

I'd recommend a plugin in any case, since it's easy to lose track of what you've changed and where you've changed it. :kaothx:
 

Oscar92player

Veteran
Veteran
Joined
Jul 26, 2012
Messages
497
Reaction score
219
First Language
Spanish
Primarily Uses
RMMV
@caethyril Can I ask you something related to this?

In the post you made for this thread, you posted a plugin that allows you to increase the speed of the animations for sprites and characters.

Is there a way to edit that plugin so it is allowed to have two animation speeds when the sprites on maps are walking or dashing?

Thanks in advance!
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,653
Reaction score
1,105
First Language
EN
Primarily Uses
RMMV
In the post you made for this thread, you posted a plugin that allows you to increase the speed of the animations for sprites and characters.

Is there a way to edit that plugin so it is allowed to have two animation speeds when the sprites on maps are walking or dashing?
Well, note that by default only the player can ever be in a "dashing" state. Dash speed in that case is walking speed (default 4, "normal") plus 1. Followers have their move speed set to that of the player, but do not otherwise register as "dashing"...by default character.isDashing() always returns false for any character other than the player.

Also, since realMoveSpeed returns the character's dashing speed or the walking speed, depending on whether they're dashing at the time, in that sense it's kinda two formulae in one already. :kaoswt:

If you want more distinction than that, you can try something like this instead~
JavaScript:
Game_CharacterBase.prototype.animationWait = function() {
  if (this.realMoveSpeed() > 4) {
    return (9 - this.realMoveSpeed()) * 1.5;  // double default anim rate
  } else {
    return (9 - this.realMoveSpeed()) * 3;
  }
};
Exactly what you put in the if statement depends on the situations for which you want to tweak the animation rate. The returned value will be the frames it waits between animation updates. :kaophew:
 

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

Latest Threads

Latest Profile Posts

// Looks at Elfkisser, realizes he'd have to either install Windows 10 or compile it for Linux
// Didn't install Elfkisser.
Too much effort for a curiosity. :popcorn:
I was just high-fiving myself for all I've learnt in the engine, and how far I've come, only to forget to remove the Immortal state from a semi-scripted battle. Now the enemy never dies and I feel so smart >.>
Playtest your stuff. Always playtest.
just spent FOREVER troubleshooting an issue with my keyboard... turns out the cord was just loose OTL
I count on someone one time, I let them promise something to me, and one week later it's complete silence as I'm completely let down. I hate everything.

Forum statistics

Threads
99,224
Messages
963,224
Members
130,813
Latest member
Gremter
Top