Draggable Objects


I had just published Cattery Collect after hunkering over it for days and felt it was working great. Then a player pointed out to me that you could just cheese the levels because you could carry the play with you. No good. So I went back in and tinkered for hours trying to get the code to work. 

Here, a platform would stop moving altogether. There, the character fell through the platform. Yet another time everything just stopped! What was really difficult was when the draggable object would move only once after the player touched it and then just freeze. 

It all began by implementing an object variable on the draggable mass called 'draggable.' Set to true, this allows the player to drag the blocks. Next, I checked to see if the player and mass are in contact with each other. If they are, the draggable variable is set to false. If the aren't, it's set to true. Then, the game checks to see if the object is being dragged. If it isn't, it sets the draggable variable to true, allowing it to be dragged. If it is being dragged, the object variable is then examined by the game in order to determine if the player is on the platform or not. If the player IS on the platform or touching the platform, it cannot be dragged. If the player IS NOT on or touching the platform, it can be dragged and used for level building. 


Whoof. What a day. I'd like to say that's it but I'll probably be obsessing over little things until the jam is done. Anyway, thanks for reading! 


-Crappie Coding



Files

cattery_collect2.zip Play in browser
Aug 03, 2022

Leave a comment

Log in with itch.io to leave a comment.