0
\$\begingroup\$

I want my object to collide with a wall (i.e not be able to walk through it), from all docs I read MovePosition should take this into account:

private void FixedUpdate()
{
    rb.MovePosition(transform.position + direction * movementSpeed * Time.deltaTime);
}

I've made sure all layers are detecting each other in physics settings and neither is marked as a trigger. What am I missing?

enter image description here

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

You've marked your object as Kinematic.

That tells the physics engine "don't worry about pushing this object away from collisions, I'll handle that part".

So, since you promised to handle that part, it's up to you to handle it. For instance, you could fire a CapsuleCast to your planned destination position, and adjust back to an earlier position if the cast hits something.

\$\endgroup\$

You must log in to answer this question.

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