How to make wall collision for game using tilemap.txt file #7141
Unanswered
Abubakar1122331
asked this question in
Q&A
Replies: 1 comment
-
Currently all movement is reliant on whether there is input, but what you really want is for the player to move, independently of input. What you want to do is split input from movement/collision detection. A sketch:
pub fn input(
// 1. We take the input
kb: Res<Input<KeyCode>>,
// 2. We set the Velocity
// I don't know what Engine is but I assume you need it for something
mut right_left_query: Query<(&mut Velocity, &mut Engine), With<Player>>,
) {
}
pub fn player_movement(
// 1. We read the Velocity
// 3. We update the Transform if there are no collisions
mut right_left_query: Query<(&Velocity, &mut Transform), With<Player>>,
// 2. We check for collisions
wall_query: Query<&Transform, (With<TileCollider>, Without<Player>)>,
) {
} Next, what you'll find is that it's moving too fast, so you'll probably need to put in a |
Beta Was this translation helpful? Give feedback.
0 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.
-
this is the txt file that im using to generate tilemap and its for pacman.
map.txt
and im using dots to make collision right now but its not working.
And here is the code:
this is the code for player movement But there is problem, i want the player to move constantly without stopping (Like the real pacman) but when i stop pressing the key the player/pacman stops.
Hope you understand what im trying to say. Can you help me with this.
Beta Was this translation helpful? Give feedback.
All reactions