Forum rules - please read before posting.

Player pushes the NPCs around. 2.5D

I'm having this weird behavior where the player pushes the NPCs around, and vice versa. You can see it in the video:

It's 2.5D. The player is R2D2. C3PO character follows the player with update frequency of 2s. The thing is that they don't seem to take account of each other when pathfinding, so it's extremely easy for them to get stuck pushing each other (and sometimes push each other off the map).

I tried disabling the capsule colliders, but then they fell through the floor. I tried increasing the mass of the NPCs to 999, but then it's easy for the NPC to trap the player in a corner, where they can't move out off. Like here:

Comments

  • The pushing behaviour is coming from Unity's Rigidbody component.

    You can try checking Is Kinematic in its Inspector, or removing it from the character's root - it doesn't necessarily need to be attached, and can be replaced with a Character Controller if you need e.g. the effects of gravity.

    The thing is that they don't seem to take account of each other when pathfinding

    If you rely on Unity's own NavMesh Agent component, characters that have this should be better at avoiding each other (though this is part of Unity itself). To have this component work with AC, attach both NavMesh Agent and AC's NavMesh Agent Integration components to the character's root.

  • edited December 2022

    Thanks for the response. I tried this:

    If you rely on Unity's own NavMesh Agent component, characters that have this should be better at avoiding each other (though this is part of Unity itself). To have this component work with AC, attach both NavMesh Agent and AC's NavMesh Agent Integration components to the character's root.

    I needed to activate Is Kinematic in the Rigidbody component, otherwise they jittered when using AC "Move to point", and sometimes they bounced around the map.

    Also, the characters seemed to float, hoovering a few cm over the floor. I solved this by baking the Height Mesh (under Advanced) in the Navigation panel.

  • Characters may float if they have no means to be affected by gravity, which will be the case if you make the Rigidbody kinematic.

    It would be worth testing out replacing your Rigidbody + Capsule Collider for a Character Controller, which should also be able to sort of the need for a Height Mesh.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.