I have a system where players are able to select tiles. As feedback, tiles slightly grow when hovered over, although I’ve ran into an issue where not only can several tiles be selected at once, but they cannot be unselected until the mouse isn’t hovering on any instance of the given tile.
hello! the two problems a you mensioned are common problems i encountered many times. and fixed many times.
two aquares can be selected at once but shoulnt be:
this happens because the cursor, while hovering on a square, make that square bigger which makes it overlap on another square. If your mouse happens to fall on this overlapping section, the event triggered by “mouse is in collision with movement block” will pick those two blocks.
to fix this you could make sure that only a single object is picked. ex: pick closest instance.
blocks keep their bigger size until the cursor is not on any block:
this happens because the event that check the reversed collision has no object picking (all instances are picked). This means that the “event that sets the variable selected to false”, will remain false if the cursor is currently colliding with any blocks.
to fix this… add the variable that filters the picking list to only the selected square. as a parent event, not simply above it. (which would successfully pick the selected block to be checked in the condition)
adittionally, the reverse collision often cannot be reversed normally using (j) key. you need to use a “not”. here is a video that explains reverse collision problems: https://www.youtube.com/watch?v=aQQQ8ZgIHf4&t=7s
but there is a simpler solution that doges all this. and im making an example project to show you.
Sorry, new problem now…I’m trying to play a sound effect after each one is hovered over, but even if I add it as a sub event of the main events, it only plays whenever the mouse collides with the blocks for the first time.
As well, for future reference, how can I ensure that after clicking on a tile, the player will go to the selected one? Or can I just return the position of the one already selected?
indeed. this method of not using trigger onces makes it hard to put a sound effect because sound effects cannot be triggered multiple times otherwise its weird…
let me think.
i didnt know you needed sounds. perhaps this method is not sound friendly, and it may be better to use the method you first used but “fixed” instead
or… maybe you were planning to have an ID associated with each block, or maybe you already have an ID system for your blocks. this could fix it but its not worth it to do just for sound effects, you would need to need it elsewhere to justify its implementation.
It might actually be. Here, I’ll explain the mechanic.
Right, so at the start of your turn, movement squares shoot out of your character in all four directions. You start with two, but for each point of speed you have, you gain another.
You can click on any of the squares to advance to that tile and end your turn, or if one hits a wall or some such, you can shoot at it, although you obviously can’t advance over walls.
If another player comes within your radius, you can shoot them. They don’t have to be within one of the squares, they can be in between.