Hi, I am testing out BabylonJS and when there is a collision I want to move back to the previous non-intersecting position. I made a little demo where I keep track of the previous position. But it isn’t working which has me kind of stumped. Coming from a functional background I would have expected this to work. I made a little demo where my sphere should reverse direction once it collides. Instead, it gets stuck inside the box:
Thank you!
Is this a very expensive operation to do at a larger scale? I googled it and going past a thousand objects seems to slow that method down considerably.
Would it be better to do game logic / collision / movement outside BabylonJS and then update the meshes from my array of game objects?
(I was planning to do it that way initially but I don’t want to deal with writing my own move/rotate/collision detection when that is build into the objects already)
If the mesh is rotating, scaling or moving, it happens every frame, as this updated matrix is what is being sent to the GPU in order to render the mesh. If I’m not mistaken, a flag is set, preventing the engine to recalculate the matrix when you manually do it, so there should be no performance penalty.
Are you talking about worker threads? Almost anything long-running or compute intensive you can put in a thread is a plus. You’ll have to try it out yourself, though, and see if you are happy with the result, as the messaging to- and from threads is not completely instantaneous, and might result in a bit of jigger.
No what I meant was if I should treat babylonjs as the “view” and run my game logic on a separate set of game structures and then map their state onto my babylonjs view