1
\$\begingroup\$

Background Info

I'm currently following the FPS tutorial from the official site. By the end of Part 1, there is a Player object implemented as a KinematicBody and controlled by player input, and a few cubic blocks scattered around, implemented as RigidBodies. The KinematicBody is moved with the move_and_slide function that takes static colliders into account, so the player is able to stand on the floor and bump into walls.

However, the player can't bump into or stand on the cubes. If you attempt to jump onto a cube, it will slide from under you. If you try to push a cube into a wall, it will glitch around a little, then slide away, without even slowing you down. The cubes have no power to stop the KinematicBody from moving through them.

Question

How can I change the behaviour to make it possible for a KinematicBody to stand on a RigidBody?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

move_and_slide has a parameter called infinite_inertia which defaults to true:

If infinite_inertia is true, body will be able to push RigidBody nodes, but it won’t also detect any collisions with them. If false, it will interact with RigidBody nodes like with StaticBody.

Try passing false instead, like so:

vel = move_and_slide(vel,Vector3(0,1,0), 0.05, 4, deg2rad(MAX_SLOPE_ANGLE), false)

Now the boxes will slow you down as you push against them, and you should be able to jump on top of them.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .