Transform picking coordinates #23791
Replies: 1 comment 2 replies
You can check the viewport example to see how to convert cursor position to world position: https://bevy.org/examples/2d-rendering/2d-viewport-to-world/ |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi,
In a 2d project, I'm trying to transform the hit position of a click to the coordinate system of an entity, so that I can calculate the difference between that entity's current position and where the window was clicked. I haven't been able to find an example for that. I've tried to use the mesh picking example because it actually uses the hit position, but it doesn't have this kind of translation.
Ideally I'd like to understand how to get whatever transform the event is using, convert it to a global transform, and then convert it to the entity's transform in a different system.
To be less vague about my use case,, I want to be able to click on the window and make the entity move towards the click. Like in a point'n'click. I'll add pathfinding later.
I'm using the picker because later I want to be able to handle a range of interactions, observe pointer events over sprites, etc. I'm new to Bevy (I've used other engines such as LibGDX and Godot) but I'm struggling with using Bevy's transforms.
Thanks!
All reactions