FunkinCrew / Funkin

A rhythm game made with HaxeFlixel
https://www.newgrounds.com/portal/view/770371
Other
2.92k stars 2.26k forks source link

Bug Report: [Character's offsets change when hitting notes if their scale is different from 1] #2543

Open Venesio opened 4 months ago

Venesio commented 4 months ago

Please check for duplicates or similar issues, as well performing simple troubleshooting steps (such as clearing cookies, clearing AppData, trying another browser) before submitting an issue.

If you are playing the game in a browser, what site are you playing it from?

If you are playing the game in a browser, what browser are you using?

What version of the game are you using? Look in the bottom left corner of the main menu. (ex: 0.2.7, 0.2.1, shit like that)

v0.3.2

Have you identified any steps to reproduce the bug? If so, please describe them below in as much detail as possible. Use images if possible.

image

https://github.com/FunkinCrew/Funkin/assets/97074204/1ab2c63a-461c-4a48-8414-bf21c3e76081

Please describe your issue. Provide extensive detail and images if possible.

If the character's scale is different from 1 in their JSON file, their offsets change with each animation and they start flying to another direction.

If you're game is FROZEN and you're playing a web version, press F12 to open up browser dev window, and go to console, and copy-paste whatever red error you're getting

objShaggy commented 4 months ago

Such things are always bound to happen due to offsets not being calculated with the scale and I don't think they're ever gonna fix this.

VocalFan commented 3 months ago

https://github.com/gusborg88/fnf-porter

We're encountering this issue a LOT when we import the scale value from Psych Engine characters to Base Game that use the scale value.

SarahDrewington commented 3 months ago

Really hope this issue gets fixed.

Mlaofmd commented 2 months ago

You can fix that

go to ... yourmod/scripts/characters/ and create your character script yourcharactername.hxc

and copy this, but change names!

import funkin.play.character.SparrowCharacter;

class YourCharNameCharacter extends SparrowCharacter {
    function new() {
        super('yourcharacter');
    }

    // script by Nebula_Zorua
    // retry fix by TormentedProgram
    // please leave this credit in

    override function set_animOffsets(value:Array<Float>) {
        if(animOffsets == null)
            animOffsets = [0, 0];

        if(animOffsets[0] == value[0] && animOffsets[1] == value[1])
            return value;

        var scaleX = scale.x / (isPixel ? 6 : 1);
        var scaleY = scale.y / (isPixel ? 6 : 1);

        var scaledNewX = value[0] * scaleX;
        var scaledNewY = value[1] * scaleY;
        var scaledOldX = animOffsets[0] * scaleX;
        var scaledOldY = animOffsets[1] * scaleY;
        var xDiff = scaledOldX - scaledNewX;
        var yDiff = scaledOldY - scaledNewY;

        x = x + xDiff;
        y = y + yDiff;

        animOffsets[0] = value[0];
        animOffsets[1] = value[1];

        return value;
    }

    override function onCountdownStart(event) {
        super.onCountdownStart(event);
        setScale(_data.scale);  //scale breaks on retry this fixes that
    }
}