I am making a game that's sort of a sokoban. So far I have player movement and when you walk into a wall, if possible, it will run it's interact function. We also have a crate, which is a wall I'd like to push. The issue being that I'd like this to chain with other crates no matter the ammount. That means, I need someone to help me make a system of checking if the wall in front can move.
How I'd imagine this:
Player interacts with crate -> Crate gets the player's moveDir -> Crate checks in moveDir direction for obstacles -> If none, proceed to move and return true to let the previous crate/player move -- If something is encountered, check if it's a crate -- If yes, ask it to check further.
https://hatebin.com/jsrwjlvtpn << Player Script
https://hatebin.com/mpqqqfzmep << Wall Script
https://hatebin.com/qnerftymbo << Crate Script
The biggest issue with this I see is we need some way to check for crates without using a string variable like wallType. If it's a crate, it has a special function that returns a boolean and grabs the moveDir as an argument. This would chain nicely and stuff.
Does anyone have an idea how I could make all this work?