flame icon indicating copy to clipboard operation
flame copied to clipboard

lookAt() does not account for negative scale values

Open gnarhard opened this issue 7 months ago • 10 comments

What happened?

the method 'lookAt()' will not look at the correct target vector if the parent's scale is negative.

What do you expect?

lookAt() should check for the component's scale while calculating its angle.

How can we reproduce this?

No response

What steps should take to fix this?

No response

Do have an example of where the bug occurs?

No response

Relevant log output


Execute in a terminal and put output into the code block below

Output of: flutter doctor -v

Affected platforms

All

Other information

No response

Are you interested in working on a PR for this?

  • [ ] I want to work on this

gnarhard avatar Jun 15 '25 03:06 gnarhard

Can you try this branch (I haven't had time to try it yet):

dependency_overrides:
  flame:
    git:
      url: https://github.com/flame-engine/flame.git
      ref: fix/look-at-to-take-scale-into-consideration
      path: packages/flame

spydon avatar Jun 15 '25 19:06 spydon

https://github.com/user-attachments/assets/3f6c22af-3776-4a51-a978-7e0fda0295f3

scale: Vector2(-1, 1) lookAt DOES NOT work correctly. See video for example. scale: Vector2(1, -1) lookAt DOES NOT work correctly. See video for example. scale: Vector2(-1, -1) lookAt works correctly. scale: Vector2(1, 1) lookAt works correctly.

gnarhard avatar Jun 15 '25 20:06 gnarhard

Aah right, of course that wouldn't work. I'll try to do it on a lower level. Haha, apparently not the first time I've looked into this:

Image

spydon avatar Jun 15 '25 20:06 spydon

Bahaha that's amazing.

gnarhard avatar Jun 15 '25 20:06 gnarhard

@gnarhard could you try now? I just pushed to the branch (still untested from my side, too much multi-tasking 😬 ).

spydon avatar Jun 15 '25 20:06 spydon

Same results

gnarhard avatar Jun 15 '25 20:06 gnarhard

@gnarhard I just pushed again (did a silly mistake in the last commit), third time's the charm? 🤞

spydon avatar Jun 15 '25 20:06 spydon

Still spazzin :/

gnarhard avatar Jun 15 '25 20:06 gnarhard

Still spazzin :/

Curious, exactly the same? I'll write some tests for this tomorrow.

spydon avatar Jun 15 '25 20:06 spydon

Yes, same. Sounds good!

gnarhard avatar Jun 15 '25 21:06 gnarhard

@gnarhard are you using nativeAngle?

spydon avatar Jun 16 '25 08:06 spydon

Yes.

gnarhard avatar Jun 16 '25 16:06 gnarhard

Can you try if the jitter also happens without a nativeAngle? I think I have to take that one into consideration somehow too.

spydon avatar Jun 17 '25 12:06 spydon

Jitter is happening with or without nativeAngle.

gnarhard avatar Jun 17 '25 16:06 gnarhard