RMMV Skill Animation Layer Order help

Random Panda

Veteran
Veteran
Joined
May 3, 2016
Messages
91
Reaction score
14
First Language
English
Primarily Uses
RMMV
I've been trying to tackle this one for a while. I would like to find a way for a Skills animation to play in front or behind of a target depending on its position. Currently the animations play on a layer above everything. For example, if there were two enemies, Target 1 and Target 2 and you attacked Target 2 which was in the back, the Skill animation would still play on Target 2 but the animation would play in front of both targets. When it actually would look more accurate if it played on top of Target 2 but behind Target 1.

I found this forum post:

They had some success by altering this code:

Code:
Sprite_Battler.prototype.setupAnimation = function() {
    while (this._battler.isAnimationRequested()) {
        var data = this._battler.shiftAnimation();
        var animation = $dataAnimations[data.animationId];
        var mirror = data.mirror;
        var delay = animation.position === 3 ? 0 : data.delay;
        this.startAnimation(animation, mirror, delay);
        for (var i = 0; i < this._animationSprites.length; i++) {
            var sprite = this._animationSprites[i];
            sprite.visible = this._battler.isSpriteVisible();

        //New stuff added
        if (animation.position < 3) { this.addChild(sprite); };  
        //New Stuff Added

        }
    }
};
And like the original poster said, it worked perfectly for the Actors, but it no longer lines up the animations on enemies that are targeted. Does anyone have any ideas how I could fix that? Alternatively, if I could make it so the added code only affects actors, I could make the work too. Something along the line of:
"If animation is for actor do if (animation.position < 3) { this.addChild(sprite); }; else do nothing."
In a perfect world I would love to have it work for both but I'll take what I can get.
As always, thanks in advance for any help of advice you can give. It's greatly appreciated.
 

Random Panda

Veteran
Veteran
Joined
May 3, 2016
Messages
91
Reaction score
14
First Language
English
Primarily Uses
RMMV
I appreciate the response. I am already using that bit of code and it does get me a small part of the way there. However, I'm trying to get animations to play on and enemy or actor between two other enemies or actors so the animation would be above certain sprites and below others. But I genuinly appreciate the help.
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
776
Reaction score
488
First Language
English
Primarily Uses
RMMV
I appreciate the response. I am already using that bit of code and it does get me a small part of the way there. However, I'm trying to get animations to play on and enemy or actor between two other enemies or actors so the animation would be above certain sprites and below others. But I genuinly appreciate the help.
I think what you'd need to do is set the z axis of the animation to the z axis of the target battler sprite +1. Since the code I shared in the other thread just sets it to -1, it ends up behind all battler sprites (err, I think anyway). You'd need to modify it so that it detects the z axis of the target and then repositions itself above only that layer.
The only thing is that I'm not sure if each battler sprite is ever actually on its own layer, or if they all share the same layer. If all battlers are on the same layer, then stuffing an animation in between two of them might be completely impossible. You'd need to look at something like YEP_BattleEngineCore, which allows you to dynamically set battler sprite priority and see how Yanfly did that.
 

Random Panda

Veteran
Veteran
Joined
May 3, 2016
Messages
91
Reaction score
14
First Language
English
Primarily Uses
RMMV
I managed to get it to work for actors which does about 75% of what I need.

I did this with:
Code:
        if (this._battler.isActor()) {
        if (animation.position < 3) { this.addChild(sprite); };   
        };
If I ever figure out how to do it with Enemies, I will definitely share. I think its because Enemy animations play on a layer that fills the whole screen and use some different method to tell where the sprites are positioned in the Database. So when you add child the enemy animations it no longer knows where to put them. I could be totally wrong there, as my coding knowledge is incredibly limited. But that's my theory so far.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:
attack on titan final season is airing tomorrow, I'm excited and scared at the same time!

Forum statistics

Threads
105,881
Messages
1,017,227
Members
137,607
Latest member
Maddo
Top