[Solved - 3D movement on X and Y with mesh colliders

Viewed 43

I am working on an Asteroids clone in 3D with top-down camera. This setup is static and will not change (so no, I do not want to transform the project to 2D game instead).

This means that I need to limit all movement to X and Y axis. I created movement for both asteroids and player and everything worked fine. All movements are done using AddForce on respective RigidBody components.

The problem is then I start dealing with collisions. I use Mesh Collider components to get a nice and precise "touch reaction". The problem is that when collision like this occurs, the new movement vector has Z value different from 0. This is a problem as the object will start moving on Z axis.

What have I tried:

  1. Freezing constraints on RigidBody
  2. Manully reseting Z in Update function

The first solution (freezing constraints) did not work and neither did the second one (moreover, the second one seems quite messy)

So the question is

What would be the optimal way to force physics-based movement only to X and Y axis while using precise collision with Mesh Colliders?

enter image description here

1 Answers
Related