Lock Y axis while moving with moveWithCollisions

I’ve just moved from using intersectsMesh to moveWithCollisions so that I could merge my world into a single mesh, but one fixed issue brought another - my character now climbs stuff, and can get under the floor! :open_mouth:…, which is kinda cool but unwanted.

Is there a way to prevent any movement on the Y axis?

Things I tried:

  1. Adding an invisible ceiling exactly at the top of the character. That did not work, the mesh was able to force itself through the ceiling somehow
  2. Wrap each mech in a container that has the same height as the character - sorta works, can’t merge into the final mesh as bullets would get stuck mid air in an invisible wall, so means more meshes.
  3. Gravity - does not work for me, as I use a static height for everything (there’s no vertical aiming)

So basically, I want to move my mesh with collisions but prevent it to climb and get underneath things.

Possible?

Thanks!

Oh man I am such a GOOF!

I always overcomplicate things and spam the forum with question that have such an easy fix, that I figure out 20 seconds after posting…

this.pivot.moveWithCollisions(new Vector3(x, 0, z));
this.pivot.position.y = 0;

Posting the solution if anyone ever needs it :slight_smile:

2 Likes