0 votes

I have the following situation :
- I have a player (KinematicBody2d) that is controlled via WASD-Keys
- Enemies (RigidBody2d) moving towards the player

The problem:
- I want the player to be able to push the enemies away when walking through them
- the enemies can move (should move towards the player) and should also be able to push themselves away
- however, the enemies shouldn't be able to push the player around

For that the player is a KinematicBody2d and the enemies are RigidBody2d with mode character (to prevent them from spinning when they get pushed)
Now I need to move (and slide) the rigid body's towards the player while they can push themselves away

When I set the enemy type to KinematicBody2d I can move and slide them towards the player, but then nobody is able to push them away. And a rigid body can't be moved directly.

Can somebody help me?

in Engine by (24 points)
edited by

1 Answer

+1 vote

Rigid bodies cant be moved with moveandslide use apply_impulse or similar.

by (316 points)
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.