Open Abubakar1122331 opened 11 months ago
There's a system in the platformer example that does this sort of thing, but fyi the platformer example uses rapier
for physics/collision. Naively, you could spawn a collider for every Wall
tile, and even do so through LdtkIntCell
registration, but this leaves you with a lot of colliders in a level which slows things down a lot.
Instead, the platformer example uses the Wall
component as a marker, then has a separate system that "merges" wall tiles into new, fewer, larger rectangle collider entities: https://github.com/Trouv/bevy_ecs_ldtk/blob/v0.8.0/examples/platformer/systems.rs#L78
Though, it doesn't look like you're spawning these components in any way. Be sure to do so either through the registering LdtkEntity
/LdtkIntCell
bundles to the app, or by fleshing them out in a system that queries for Added<EntityInstance>
or Added<IntGridCell>
, or some combination of the two: https://docs.rs/bevy_ecs_ldtk/latest/bevy_ecs_ldtk/#entity-and-intgrid-layers
I want to add collision for any these ldtk. Tell me how do you separate tiles for collision and add colliders to it.
Here's my main.rs:
This is my systems.rs:
components.rs: