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

[feature/automatic-offset-flipping] Attribute Is Facing Right #3556

Conversation

lemz1
Copy link
Contributor

@lemz1 lemz1 commented Oct 3, 2024

FIXES / CHANGES

  • Adds isFacingRight attribute to character data
  • Reverts tankman.json

By using isFacingRight, we can fix the problem of wrong animations and broken offsets

Default is true

if a character seems to have broken offsets, set isFacingRight to false, and see if that fixes it.

@EliteMasterEric
Copy link
Member

Why can't you just use the default value of flipX?

@lemz1
Copy link
Contributor Author

lemz1 commented Oct 4, 2024

lets look at tankman as an example:
_data.flipX is true,
and his offsets are made for when he is the opponent

problem:
when he is the opponent BaseCharacter.flipX is true,
we implemented it that when flipX is true we need to flip offsets and anims,
however this shouldn't happen here, since his offsets and anims are already correct.
Exactly for this reason i added the isFacingRight attribute

note:
im pretty sure this is what that animOffsets[0] *= -1
CharacterRegistry was for, however that is an incorrect calculation

@EliteMasterEric
Copy link
Member

we implemented it that when flipX is true we need to flip offsets and anims,

But the funkin.play.stage.Stage#addCharacter() function data applies either the flipX value, or the inverse of that value!

So if a character has flipX = true in their data, then BaseCharacter.flipX will become false when they switch sides.

animOffsets[0] *= -1 is supposed to account for this, but if that calculation is incorrect, then we just need to apply the correct one.

@lemz1
Copy link
Contributor Author

lemz1 commented Oct 4, 2024

But the funkin.play.stage.Stage#addCharacter() function data applies either the flipX value, or the inverse of that value!

So if a character has flipX = true in their data, then BaseCharacter.flipX will become false when they switch sides.

grafik

it only swaps when its the character is on the player side,
but thats a problem for tankman since he will have BaseCharacter.flipX set to false, meaning it won't flip the offsets because we check if BaseCharacter.flipX is true and only then flip offsets and anims

// {
// for (anim in result.animations)
// {
// anim.offsets[0] *= -1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the calculation we actually need is one similar to this:

output.x += (animOffsets[0] * 2 + (width - frameWidth)) * this.scale.x;

Copy link
Contributor Author

@lemz1 lemz1 Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but im pretty sure even if we have the correct calculation, there will still be edge cases.
so i might just write a python script to automatically set isFacingRight to the correct value (just need to hope there is some library that can help me do that, although i kinda doubt that such a library exists)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the calculation we actually need is one similar to this:

output.x += (animOffsets[0] * 2 + (width - frameWidth)) * this.scale.x;

I see, I should test this change out later.

@EliteMasterEric
Copy link
Member

but thats a problem for tankman since he will have BaseCharacter.flipX set to false, meaning it won't flip the offsets because we check if BaseCharacter.flipX is true and only then flip offsets and anims

That's what the anim.offsets flip in the CharacterRegistry is for!

@lemz1
Copy link
Contributor Author

lemz1 commented Oct 4, 2024

That's what the anim.offsets flip in the CharacterRegistry is for!

yeah, but the calculation is wrong

@lemz1
Copy link
Contributor Author

lemz1 commented Oct 4, 2024

i'll close this since #3543 does it nicer, and also has some other useful stuff

@lemz1 lemz1 closed this Oct 4, 2024
@lemz1 lemz1 deleted the feature/automatic-offset-flipping branch October 4, 2024 12:45
@AbnormalPoof AbnormalPoof added the status: rejected Issue did not pass review or PR cannot be approved. label Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: rejected Issue did not pass review or PR cannot be approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants