I am trying to make a classic-style board game into a 3d game. My current goal is to make a system where the player can click on a boat (gray part right now) and it will then follow their mouse position over the game board. The tiles that the boat covers highlight green. There are three different sizes: 1 tile boat, 2 tile boat, 3 tile boat. This should be signified by the number of tiles lit up with the boat is hovered over them. Ideally, the boat would latch into exactly where it hypothetically would go if player clicks when hovering over. But for now im just trying (and failing) to the get basic hover functionality.
I had it half-way working by starting a renderstepping function when the player clicks on the boat, and moving the boats cframe to the players mouse.Hit.Position. This, however, caused it to not trigger the part.Touched property as it uses no physics. So I added a part inside of the boat part which I tried to make follow the boat using linearvelocity so it could trigger the tiles. However, it doesn't move for some reason and I don't know why.
Also, using mouse hit cframes created the problem of the mouse hit being on top of the part, and looping this overlap to make the part fly towards the screen. To fix this, I opted (with AI's advice) to use raycasting and filter out the part from the raycast parameters. This had some annoying consequences, though, as the part no longer follows exactly where the mouse appears to be on screen, and the player can no longer click the part a second time to stop the renderstepping. Also, as seen in the video, it breaks apart terrible when interacting with multiple boats and somehow the part-flying-towards-the-screen issue returns 😂 .
The video shows how it breaks down in real time lol. I also linked a text file including my code. If there's a better way to show you the code let me know.
I have just begun learning to script and this is driving me crazy. I'm really not sure how to fix it. Thank you for any help!