Funkin icon indicating copy to clipboard operation
Funkin copied to clipboard

Bug Report: characters scale bug

Open khuonghoanghuy opened this issue 1 year ago • 3 comments

Describe the bug

When i add the scale on bf.json (or many other characters) if seem like that character when hit note will change the postion

To Reproduce

  1. open assets/data/characters
  2. open bf.json
  3. add "scale": 1.2
  4. this bug happen

Expected behavior

it should be bigger and still in that postion

Screenshots/Video

https://github.com/FunkinCrew/Funkin/assets/63274635/09ed0d00-6f79-4642-9d89-685f6eefd76a

Desktop

  • OS: Windows 11
  • Browser: Chrome
  • Version: v0.4.1

Additional context

khuonghoanghuy avatar Jun 20 '24 10:06 khuonghoanghuy

This has been known for a good while and there's even a PR for it, yet the devs still haven't fixed it

Keoiki avatar Jun 20 '24 13:06 Keoiki

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
    }
}

Mlaofmd avatar Jun 22 '24 23:06 Mlaofmd

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
    }
}

Is Working, Thank you so much! :D

khuonghoanghuy avatar Jun 23 '24 01:06 khuonghoanghuy

This issue is likely fixed as of 0.5.3 Has anyone run into it lately?

Hundrec avatar Oct 25 '24 01:10 Hundrec

It was fixed back in v0.5.0.

AbnormalPoof avatar Oct 25 '24 01:10 AbnormalPoof

Thanks for the confirmation! We can close this issue now.

Hundrec avatar Oct 25 '24 01:10 Hundrec

This issue is a duplicate. Please direct all discussion to the original issue.

github-actions[bot] avatar May 16 '25 11:05 github-actions[bot]