0 votes

`Hello, Godot community.

I am fairly new to game development, and I have been trying to make this Sokoban clone in Godot. I got the player input and movement working. I also got the collision with certain blocks working. However, I can't figure out how to make the player move the boxes.

Here is the player script:

extends KinematicBody2D


func _fixed_process(delta):
    if(Input.is_action_pressed("player_down")):
        move(Vector2(0,8))
    if(Input.is_action_pressed("player_up")):
        move(Vector2(0,-8))
    if(Input.is_action_pressed("player_left")):
        move(Vector2(-8,0))
    if(Input.is_action_pressed("player_right")):
        move(Vector2(8,0))

func _ready():
    set_fixed_process(true)
    pass

Both the player and the box are kinematic bodies with their own collision shapes in their own scenes. I am instantiating both of them in a different level scene.

Thanks beforehand.

in Engine by (21 points)

1 Answer

0 votes
Best answer

Kinematic bodies aren't affected by physics, so your blocks need to be RigidBodys.

by (56 points)
selected by
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 Frequently asked questions and 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 [email protected] with your username.