-
-
Notifications
You must be signed in to change notification settings - Fork 934
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
feat: Add lookAt method for PositionComponent #1891
Conversation
@st-pasha didn't you make a function like this once? But for Radiance maybe? I think you had another name for it if I remember correctly. |
Found it, #1107 should be done before, or together with this |
The angle will be in regards to the angulaOffset, but you don't have to do canvas transformations to achieve that, because the sprite is already rotated in that direction. So if you have a sprite looking to the right and set |
Okay, I think I get what you mean conceptually. Will have to play around with the code to wrap my head around it. I'll make modifications to this PR accordingly. I'm marking this as draft till I get it working. |
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.
Almost there! Just two comments
packages/flame/lib/src/collisions/hitboxes/composite_hitbox.dart
Outdated
Show resolved
Hide resolved
- Adds `angleTo` method which returns the calculated angle - Refactors `lookAt` to use `angleTo` - Improves doc comments
It would be good with some docs for this and a tiny example in the examples directory (or an embedded example in the docs). |
Here we go LookAtExamples.mp4 |
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.
Just some tiny things left!
Description
This PR adds a new method called
lookAt
forPositionComponent
. It is a convenience method which rotates the component to make it point towards/look at the given target position.Additionally, this PR also adds a
angleTo
method which can be used to get the calculated angle forlookAt
. It will be useful if someone want to smoothly rotate towards target using effects or manual lerping.Checklist
fix:
,feat:
,docs:
etc).docs
and added dartdoc comments with///
.examples
.Breaking Change
Related Issues
Fixes #1107