-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
godotproject/Player.gd
Outdated
if velocity.x > 0: | ||
scale.x = initial_scale.x * sign(scale.y) | ||
elif velocity.x < 0: | ||
scale.x = -initial_scale.x * sign(scale.y) |
There was a problem hiding this comment.
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:
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 |
There was a problem hiding this comment.
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
There was a problem hiding this 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
There was a problem hiding this 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. 👍
Inverting based on the scale of the root node so that collision area flips with the sprite (sprite not symmetrical)