Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(1 edit)

IJ, once again I'm in need of guidance. 

I have a question regarding the rect module. I'll ask here to avoid creating new posts:

is there a way to have to use rect.constrain to keep a draggable canvas outside of a container instead of inside? I wanted to create backgrounds with "pseudo-collision", for example, making it impossible to drag your character onto a table or keeping the character within odd-shaped spaces. 

In the following image, I drew an X over areas I want to keep the draggable character away from.


Thank you!

(+1)

Constraining an object within a concave shape while dragging is a rather difficult problem. You can easily construct examples that have no single "closest valid location"


In the general case I think this would probably require some kind of iterative solver.

If all you care about is the destination, you could use several calls to rect.overlaps[] to see if the player object overlaps any obstacles and "snap back" as demonstrated in the examples.

I see! 

Thank you for answering; the snap back workaround will do just fine!