How to make my character push a crate?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Montasir Raihan

Hello there. I’m new in game development and learning how to make a perfect 2D top down puzzle game. The thing is I want to make my character push an object. Objects like boxes or crates. I just don’t know how to do it. Any advice, please? Thank you in advance.

:bust_in_silhouette: Reply From: dari0us

Id use a KinematicBody2D to tackle the collisions problem, as it would do it automatically.
To push the crate, inside the crate script, i would check if it was colliding with the player, and if it was, then get the direction from the center of the crate to the player. Having all that, you should be able to use the direction variable, to push it away from the player.

But if you’re really new to this sort of thing, you can easily get away with a
RigidBody2D crate, which would just calculate all the physics for you.

Thank you very much.

Montasir Raihan | 2021-05-06 11:23

:bust_in_silhouette: Reply From: timothybrentwood

Here is a great tutorial series that explains how to do just what you want to do. You’ll learn how to do the basics the correct way, I highly suggest you check it out.

Tutorials are the only way to learn specific things that you dont yet know how to do.
The more you watch them, the easier it gets to do things independently.

dari0us | 2021-05-06 11:32