[FIXED]How to stop a player from accidently eliminating themselves?

I’m trying to make a game similar to chess and rock paper scissors. There’s the Bow, Pegasus, and Sword. It’s a two-player game turn-based game, and the goal is to eliminate one type of soldier.

I want to make it so that when player one is moving their piece, they don’t accidently collide with the piece that’ll eliminate them.

For example, Bow’s eliminate Pegasus, Sword eliminates Bow, and Pegasus eliminates Sword.

I’m not sure how to make it so when it’s player one’s turn and they’re moving Blue Sword, they don’t die because they went over or got too close to Red Pegasus.

Any other ideas/advice would really help!

How are the pieces being moved? You can setup a condition like a boolean variable or another condition(s) and only trigger the checker events when the move is over and the variable is true or some other action is done . You then check the move and change the boolean variable back to false.

You need something as a trigger like mouse released, object was just dropped, tween has finished, pathfinder object has reached its destination… It all depends on the method used to move the objects.

I’m using the draggable behavior to move, and when they collide, one is deleted.
So should I set it up so that when the mouse is released and the item is colliding with the enemy piece, it won’t delete?

The drag behavior has a just dropped condition. You can use it as a trigger. First you would need to check if it’s a valid move. If not, the object would move back to its previous position. There’s a cancelable drag behavior or you can move the object back yourself. Either with a set position or a tween.

I can’t really offer a lot of help at the moment but I can offer tips. There are plenty of good people on the forum.

Even if you’re just offering tips it’s still super helpful ToT lol

Do you have a tip on how to use the cancelable drag behavior if it doesn’t make a valid move?

The behavior has a cancel drag action. Make sure the object is still picked and trigger the action and it will move to its previous location.

I changed it so blue’s are in one sprite and Reds are in one sprite, and its different animations. And i applied what you said, like using the drop as a trigger and IT WORKED!!! Thanks so much!!!

1 Like