Forum rules - please read before posting.

Character bouncing against walls

I feel like this would be super common but couldn't seem to find a fix in the forum here. I have direct movement on and rigidbod set up to stop the characters at colliders. They seem to continuously bounce up against the walls though: https://drive.google.com/file/d/1CYYPKj5Lg7fy_V7wtrVHop44ubO0I88m/view?usp=sharing

The top is the player character and the bottom is an NPC set to follow (so they are bouncing while trying to go up to the player). Not finding any settings anywhere that is getting them to not bounce so obviously. Anyone get this and know how to fix?

Comments

  • Ah actually, I had the rigid body set up but the character was not actually moving with it. In the physics settings I needed to enable "Move with Rigidbody 2D". Doing that mixed with "Continuous" setting in the collision detection setting on the rigid bod seemed to fix both the player and the NPC following.

  • Glad you've fixed the bouncing.

    To stop the NPC from attempting to go "through" the collider, you'll also need to define a NavMesh in the scene - which should describe the area that characters can move around in.

    To move around an obstacle such as the collider, you'll need to define a "hole" in that NavMesh of the same shape - see this tutorial.

  • Oh, I will definitely try that! Since I was using direct control for the player I figured it wasn't needed but that totally makes sense for the following NPC.

  • edited January 2021

    Got that navmesh going and my follow character is working excellent! but now my direct movement protagonist goes right through those holes, hehe. Was there something different I needed on the setup to make sure the direct control character is still stopped by those polygon colliders?

    Edit: Seeing how the follow character uses the nav mesh, I don't think they need the rigid body. I can remove to have them not be blocked by colliders. This does seem to mean that each "hole" in the mesh means i need two separate collider objects. 1 for the mesh hole and 1 for the direct movement character collision.

  • When using Direct control, you'll need physical colliders (i.e. not just Colliders with Is Trigger checked) in order to block Player movement.

    If you want Direct movement, as well as pathfinding, you will need two sets of Colliders, yes. In a 3D game this can often be the same object(s), but in 2D they need to be separate.

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.