Moving Checker Mesh Based on Click


I am creating a Checkers game in Babylon. Right now, I have a checkerboard made out of 64 cube meshes in an 8x8 pattern and cylinder meshes placed on top of them as checker pieces. They all have unique IDs, and I can click them to find the value of this.

My main “roadblock” right now is being able to click a checker piece, then go on and click another mesh that I want to move it to. Currently, I can only click a mesh and get its ID. I want to be able to select another mesh to move it to. How would this be done?

Here is a playground of my current program: Babylon.js Playground

Any help is appreciated! Thanks!

EDIT: Another approach I’ve considered is being able to drag the checkers piece and attach it to a checkerboard square. I’m thinking I can check if it’s in contact with the board by using collisions?

You need to implement your own state to keep track of the previous selection to allow this. I added some starting points here:

1 Like

Thanks! This was really helpful