0 votes

As you can see in the photo, I have a kinematic body as a player and a wall as a static body.
They both have collision shapes. The problem is that the player is able to walk through the wall.
Note: The wall scene is smaller, the instanced scene is resized. If I change the wall to be a rigid body, the collision works but it resizes in the wrong way (the engine also tells that there may be problems with resizing rigid bodies - Godot 3.1 stable). So what's the problem? I can't use static bodies to make walls?

in Engine by (402 points)

"resizing" is a bit of an arbitrary term. Do you scale or edit the extents?

You should keep the scale of the statticbody and the collision shape at 1. Instead edit the extents of the collision shape. If you use several instances of your wall scene then make the subnodes editable and make the collision box shape of each collision shape unique. (if you don't, all shapes will change if you edit one.)

I changed a few things. In the wall scene I left the entire thing un-scaled and in the main scene i scaled it (under transform - translation). It still doesn't work. I added in the scene another static body which had a box collision shape. And the player was just going through it. Strange, because it works if i change that static body to a rigid body. So the problem is that my player can't detect static bodies... :(
EDIT: The wall still works if i make it a rigid body but if i change it to a rigid static body (from the inspector - mode:rigid) it doesn't work.

1 Answer

+1 vote
Best answer

Solved. It was a problem with the player script. Apparently, if a kinematic body is using translate() to move in the world, for some reason it will not detect static bodies (i mean their collision shapes)

by (402 points)

Yes, you must move a kinematic body with move_and_collide() or move_and_slide() if you want it to detect collisions.

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.