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.

asked Aug 18, 2017 in Engine by Mohan (21 points)

1 Answer

0 votes
Best answer

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

answered Aug 19, 2017 by AngryTomato (56 points)
selected Aug 19, 2017 by Mohan
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.