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

Collision area flips horizontally when user changes direction #90

Merged
merged 2 commits into from
Mar 30, 2021

Conversation

allisonchristensen
Copy link
Collaborator

Inverting based on the scale of the root node so that collision area flips with the sprite (sprite not symmetrical)

Comment on lines 411 to 414
if velocity.x > 0:
scale.x = initial_scale.x * sign(scale.y)
elif velocity.x < 0:
scale.x = -initial_scale.x * sign(scale.y)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Quick q, why is scale.y involved here? I can't tell why it would be...
Also I think we can use the facing variable, so maybe the code could look something like:

Suggested change
if velocity.x > 0:
scale.x = initial_scale.x * sign(scale.y)
elif velocity.x < 0:
scale.x = -initial_scale.x * sign(scale.y)
scale.x = sign(facing.x) * initial_scale.x

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TBH I'm not 100% sure why scale.y needs to be involved here - could be because the initial scale isn't (1,1)? So far it's the only way I've found that keeps the sprite from flickering between left and right. I tried it out and your suggested change results in this flickering too unless I multiply scale.y. I'm going off of the comments in this issue: godotengine/godot#12335

Copy link
Collaborator

@charasyn charasyn left a comment

Choose a reason for hiding this comment

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

See the comment below/above? The other comment I left

Copy link
Collaborator

@charasyn charasyn left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for the explanation. That's super weird.
LGTM. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants