How to make wall collision for game using tilemap (txt file). #7073
Unanswered
Abubakar1122331
asked this question in
Q&A
Replies: 0 comments
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.
-
I want my player to not cross the wall.
Here is my map.txt file.
map.txt
And here is my code.
pub fn check_wall_collision( target_player_pos: Vec3, wall_query: &Query<&Transform, (With<TileCollider>, Without<Player>)>, ) -> bool { for wall_transform in wall_query.iter() { let collision = collide( target_player_pos, Vec2::new(16.0, 15.0), wall_transform.translation, Vec2::new(1.0, 1.0) ); if collision.is_some() { return false; } } true }
Here is Second Piece which is using map.txt file.
`pub fn map_collision(
mut commands: Commands,
asset_server: Res,
mut windows: ResMut,
mut texture_atlases: ResMut<Assets>,
) {
}`
Beta Was this translation helpful? Give feedback.
All reactions