I am creating an iPad interactive book using mega-fiers and was wondering how to make content on the page mesh touchable. I have seen an app on the store the does just that. I have several page meshes (from mega-fiers) that are my book’s pages and each one needs to be able to have an object stretched across the face of the mesh and able to be manipulated. The mesh can turn like a page so I need the objects to follow the contour of the page. I am new to Unity so the most low level description possible would be appreciated.
So I use Megafiers a bit - certainly not enough to do more than suggest this following - someone might have a much better idea that me I am presuming you are using the Megafiers Book script to build a book with multiple pages? I would suggest that what you do is have the items that will “float” etc as areas on the page that you map with a collider that is a child of the page mesh. Now the first problem there is that Megafier’s books only have three pages - it works by mapping in as textures onto those pages as I was suggesting in my comments above.
So your choice is to do some automatic collider generation when a page is completely turned, or actually have only a certain number of areas that can contain an interactive shape. Which you choose I guess depends on your level of coding experience and the importance of this feature in your project.
I’m sure it would be possible to have the objects deform along with the page - but I don’t have the experience of doing that and it is probably fiddly.
Let’s say you decide to have “active” areas of every page
- You need a data structure to represent the pages of your book
- This data structure would contain a list of list of information about the interactive areas of the page
- It would also contain the texture of the page
- It would contain prefabs to instantiate when the page item was activated
Each of your page meshes would need to contain the same collider areas and each would have a script attached to detect the hit. Note I don’t think these colliders will be in the right place until the page is lying flat. The easiest was would be to make a page mesh, add the colliders and then duplicate it to make the other two pages.
Your page mesh script would look for a touch on a collider in update using Physics.Raycast using the current touch position or mouse input:
- When a touch was detected you would instantiate the prefab associated with that interactive area (note, you could just have some or all of them non-interactive on certain pages).
- You would instantiate a plane with the background texture of the book page and the dimensions of the interactive area and place it over the content that initiated the interaction. > The kite appears to be a 3d object that starts from a picture of the kite on the page, which becomes invisible as the interactive object is created.
- At some point the interative object would complete its job and vanish at which point you would fade away the alpha of the plane obscuring the picture of it to make it appear back in the book context.
- You would have to disable book page turns during this interactive element to avoid strange overlaps and intersections.
You would use your page data structures to fill out the actual pages of the mega fiers book script (also setting the right number of pages of course). You would detect which page(s) was currently shown and use that to work out what to do on the collider touch.