MZ Sprite_Animation vs Sprite_AnimationMV (Effekseer Animations not showing on Map too!)

Hi,

Quick question about the Sprite_Animation object in RPG Maker MZ to play Effekseer animations, I'm having trouble getting it to display the animation with its "setup" function. It works just fine when I play a MV animation with the Sprite_AnimationMV object and use its "setup" function, but for some reason nothing appears on screen with Sprite_Animation.

Is there something I'm missing? Maybe something with the parameters? Or maybe there's something else that needs to be done for Effekseer animations to play?

Any help would be appreciated.

Thanks!
Have you compared with Spriteset_Base.prototype.createAnimationSprite?
Without seeing what you did, I couldn't tell you what you're missing. But the setup function should be called the same way for either class. Here is how the engine uses it:

JavaScript:
Spriteset_Base.prototype.createAnimationSprite = function(
    targets, animation, mirror, delay
) {
    const mv = this.isMVAnimation(animation);
    const sprite = new (mv ? Sprite_AnimationMV : Sprite_Animation)();
    const targetSprites = this.makeTargetSprites(targets);
    const baseDelay = this.animationBaseDelay();
    const previous = delay > baseDelay ? this.lastAnimationSprite() : null;
    if (this.animationShouldMirror(targets[0])) {
        mirror = !mirror;
    }
    sprite.targetObjects = targets;
    sprite.setup(targetSprites, animation, mirror, delay, previous);
    this._effectsContainer.addChild(sprite);
    this._animationSprites.push(sprite);
};
I'm coding my battle system from a blank page, so it might be harder to follow, but this is my animation code atm:

JavaScript:
Spriteset_Battlefield.prototype.playAnimation = function(anime_id, targets, posData, rate) {
    const position = {
        x: this.getAnimationPosition(posData.x, posData.userPos.x, posData.targetPos.x),
        y: this.getAnimationPosition(posData.y, posData.userPos.y, posData.targetPos.y)
    }
    const animation = $dataAnimations[anime_id];
    if (animation.effectName) {
        // If MZ animation
        var sprite = new Sprite_Animation(rate, position);
    } else {
        // If not MZ animation, using MV animation
        var sprite = new Sprite_AnimationMV(rate, position);
    }
    sprite.setup(targets, animation, false, 0);
    sprite.zIndex = 10;
    sprite.animationIndex = 0 + this._currentAnimationIndex;
    sprite.setupCallbackEndFunction(this.removeAnimationOnEnd.bind(this, sprite.animationIndex));
    this._animations.push(sprite);
    this.addChild(this._animations[this._animations.length - 1]);
    if (this._currentAnimationIndex > 1000) {
        this._currentAnimationIndex = 0;
    } else {
        this._currentAnimationIndex += 1;
    }
};

I looked at the Sprite_Animation and Spriteset_Base functions, and I can't seem to find what's wrong with my function. It's weird that regular MV animations work without any issues, but MZ animations just don't even show up (there's not even any audio).

EDIT: Hmm, is it because of the targetSprite property defined in the Spriteset_Base?
The setup method expects an array of sprites. Spriteset_Base gets these from the input battlers via its makeTargetSprites method. What are targets in your case?

The core scripts only use targetObjects to call each target's endAnimation method (if they have one). The targets array provided to createAnimationSprite can be duck-typed: all that's really needed is for makeTargetSprites and animationShouldMirror to be able to return appropriate values.
The setup method expects an array of sprites. Spriteset_Base gets these from the input battlers via its makeTargetSprites method. What are targets in your case?
It's an array sprites. Each sprites come from a object I created, but based off Sprite_Base. What kind of sprites are used in Spriteset_Base? Maybe that's the issue? It needs to be a specific kind of sprite?
but based off Sprite_Base
Are you saying that you made a prototype that inherits from Sprite_Base? If so, that could be part of the issue, since Sprite_Base doesn't exist in MZ.
Are you saying that you made a prototype that inherits from Sprite_Base? If so, that could be part of the issue, since Sprite_Base doesn't exist in MZ.
Sorry, I meant Sprite_Clickable. Still used to having the base sprite object being Sprite_Base like in MV lol.
Sprite_Clickable should be OK. 👋

By default, neither Sprite_Animation nor Sprite_AnimationMV expect arguments in their constructor. Have you changed something there as well?

Core animations update their position based on their target sprites:
  • MV: adjusts the sprite's x & y;
  • MZ: adjusts the Effekseer handle's viewport.
An important difference is that Sprite_Animation (MZ) doesn't care about its own x and y coordinates or assigned bitmap. It is simply there as a display object, redirecting render calls to its Effekseer handle.

Edit: oh, but if the sounds aren't playing then it's not like it's just animating off-screen... 😴
Yeah I thought about a position issue, but since there's no sound it's more like the animation itself is not playing. I find this really weird since MV animations work perfectly... I just really have no idea what the issue is. There's probably something more to Effekseer animations, like having not just creating the object and using the setup function.

By default, neither Sprite_Animation nor Sprite_AnimationMV expect arguments in their constructor. Have you changed something there as well?
I just added optional arguments to help update positions, but only works for MV animations, not MZ animations. They do nothing for MZ animations.
The only other thing in your code that stands out to me is your custom setupCallbackEndFunction method on the animation sprite. Maybe that is prematurely ending MZ animations?

If you haven't already, it might also be worth trying various edits, e.g. replace a working MV animation with an MZ animation (from scratch or copy+paste), test with different target types, etc, just to make sure you've identified the correct problem.
The only other thing in your code that stands out to me is your custom setupCallbackEndFunction method on the animation sprite. Maybe that is prematurely ending MZ animations?

If you haven't already, it might also be worth trying various edits, e.g. replace a working MV animation with an MZ animation (from scratch or copy+paste), test with different target types, etc, just to make sure you've identified the correct problem.
Yeah I'll have to go with trial and error. It's so weird, but I'm sure once I find the issue it will be like "Ohh that was obvious".
UPDATE: Ok this is weird, I tried a MZ animation on the map, and it didn't even work. I'm not using any plugin that modifies the Scene_Map except for Hudell's Cycle Maps for parallax mapping, and my own plugins don't really change the map, except for the changing the Message Window UI. Any idea what is happening? It's like Effekseer doesn't work at all in my project, no sound and no image. What is happening?

EDIT 1: For additional information, my project still runs an early version of MZ, v.1.1.1, might that be the cause?

EDIT 2: Updated my core to 1.7.0, and Effekseer animations still are not working. And I'm trying to use the default animations that come with MZ.

EDIT 3: Wait, it might be one of my plugins. Once I deactivated it, the animation started working on the Game Map. Will need further investigation.

EDIT 4 (SOLUTION): I finally found what caused the issues. I added some properties to Sprite_Animation and Sprite_AnimationMV to accommodate for some features in my game, and I had a typo in one of the alias function for Sprite_Animation. So it basically lost all properties in its initMembers function... Yeah, ridiculous, but everything is working now. Thanks for all the help everyone! As always it was just a dumb typo...

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/sprite_animation-vs-sprite_animationmv-effekseer-animations-not-showing-on-map-too.163777/