chandlerprall / Physijs

Physics plugin for Three.js
MIT License
2.75k stars 455 forks source link

How to move blocks out of blocks faster #317

Open mrmola opened 4 years ago

mrmola commented 4 years ago

I have made a thing where you can control a block that moves around on a voxel terrain, but when the block goes fast enough it will go into other blocks. When it is partially overlapping another block, it will not be able to be controlled. While I understand why the blocks are going into each other, I don't know how to fix it. How do I either prevent fast moving blocks from moving inside each other, or make them move out of each other faster?

zircher commented 4 years ago

There are several ways you can tackle that problem.

  1. Check each frame for fast movers and cap their speed.
  2. When fast movers are detected, Have the program look ahead for collisions before they happen and slam on the brakes.
  3. When blocks are overlapping by a given threshold, perform an 'eject' routine that searches for the nearest open space and translates the block (and probably reduces or eliminates the vectors.) Of course, none of these are features of the library and you would have to write these functions for yourself as part of the game loop.