A
atmobeat
Guest
Greetings GameMakers! One problem I am starting to run into is that tutorials often only focus on one mechanic or system, and as soon as those systems interact new challenges get introduced. That's fine but I also don't want to reinvent any wheels so I'm coming here to see if any of the more experienced programmers out there have a strategy that works well for my problem. My game is a top-down zelda-like.
I've got tile collision working on its own and object collision working on its own, but I need them working well together. The problem I have is that both collision scripts have some code for sliding/relocating the instance that can potentially move the calling instance to a slightly different location than it is trying to go. So it seems that the following situation could easily come up: (1) the player tries to move the character into a wall (call it location L1), (2) the object collision script says it's fine to move to L1 as there is no object there, (3) but the tile collision script does not and rather finds a nearby location (call it L2) to move the player to so that the instance slides along the wall for better feeling controls, (4) unfortunately, L2 is a location now overlapping an object so the object collision script now needs to find a new location L3. I think you can see that there is potential to get stuck in a loop here if the tile collision script keeps trying to slide/relocate the instance into another object and the object collision script keeps trying to move the instance back into the tile wall.
Obviously, just feeding slide locations into the other script won't work perfectly. So is it better to combine the scripts into one script? Still, how would the checks work to avoid infinite loops with sliding whether in one script or two? Does including object collision checks within a tile collision script undermine the performance gains?
Thanks for all help!
I've got tile collision working on its own and object collision working on its own, but I need them working well together. The problem I have is that both collision scripts have some code for sliding/relocating the instance that can potentially move the calling instance to a slightly different location than it is trying to go. So it seems that the following situation could easily come up: (1) the player tries to move the character into a wall (call it location L1), (2) the object collision script says it's fine to move to L1 as there is no object there, (3) but the tile collision script does not and rather finds a nearby location (call it L2) to move the player to so that the instance slides along the wall for better feeling controls, (4) unfortunately, L2 is a location now overlapping an object so the object collision script now needs to find a new location L3. I think you can see that there is potential to get stuck in a loop here if the tile collision script keeps trying to slide/relocate the instance into another object and the object collision script keeps trying to move the instance back into the tile wall.
Obviously, just feeding slide locations into the other script won't work perfectly. So is it better to combine the scripts into one script? Still, how would the checks work to avoid infinite loops with sliding whether in one script or two? Does including object collision checks within a tile collision script undermine the performance gains?
Thanks for all help!