+1 vote

Here I am. Once again. Asking a kind of different question.

I have no idea how to make this freaking box move. In my scene. I am trying to make this sokoban game work, but if I can't make this box move, then I am not going to make it.

I tried making the box node a RigidBody2D and setting the default gravity to (0,0) in the physics properties. That should avoid making it fall to the ground. But I can't make the player push it. It will just block the way of the player like a regular static body.

Please help.

Screenshot of the level:
Here is a screenshot of the level scene:

in Engine by (21 points)

1 Answer

+2 votes
Best answer

To push the block your player would have to be a RigidBody too (I'm guessing you're using KinematicBody?). And then depending on the relative masses and applied force, the block would move.

But that's typically not how Sokoban-style games work. They're definitely not using physics - it's way too complex. You just use a grid, and if the player moves into a block, you try and move the block by one square.

I recommend you check out GDQuest's tutorials on Grid-based Movement: https://www.youtube.com/watch?v=BWBD3i00AfM

by (20,895 points)
selected by

Yeah, I was thinking that this wasn't the way it was done, but I thought that I could give it a shot. I'll check out that tutorial series!

Thank you very much :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.