Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix offsets being fucked on scaled characters #2332

Closed

Conversation

nebulazorua
Copy link
Contributor

when a character is scaled they will slowly fly away

personally I think it'd be better to have a seperate animOffset point that gets added in the draw call but whatev
(this current approach of doing offsets could ESPECIALLY fuck with characters with scrollFactor not set to 1, 1!)

@nebulazorua nebulazorua changed the base branch from main to develop May 9, 2024 00:25
@Mlaofmd
Copy link

Mlaofmd commented May 29, 2024

yeah ninjamuffin please fix it

@EliteMasterEric EliteMasterEric added status: pending triage The bug or PR has not been reviewed yet. and removed character offsets labels Jun 16, 2024
@Mlaofmd
Copy link

Mlaofmd commented Jun 22, 2024

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

@EliteMasterEric EliteMasterEric added type: minor bug Involves a minor bug or issue. small A small pull request with 10 or fewer changes labels Jul 11, 2024
@EliteMasterEric EliteMasterEric deleted the branch FunkinCrew:develop July 12, 2024 00:59
@EliteMasterEric EliteMasterEric added status: rejected Issue did not pass review or PR cannot be approved. and removed status: pending triage The bug or PR has not been reviewed yet. labels Jul 13, 2024
@EliteMasterEric
Copy link
Member

Superceded by a fix I made internally when working on #2310. Definitely works now though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
small A small pull request with 10 or fewer changes status: rejected Issue did not pass review or PR cannot be approved. type: minor bug Involves a minor bug or issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants