- Home /
Design discussion/Multiple technical questions.
How could I write a script to flip pages of a book?
Using the help of the community on Unity Answers, I have created a 3D book. The game I am creating is in first-person, and the player is able to bring out their book with 'e'. Each page is made up of 2 quads, and are able to rotate on their own local axis. The book itself is complete, but I'm unsure of how to write the script that will animate the pages. It would be great if you could help me out! Thanks.
Also, I have already made a script that flips the pages fairly well, but I did it in a very ineffieciently. It was a very long, point-less script. I'm sure there are better ways to write the script. I prefer JavaScript, and excuse my vague question. I have been told that I don't usually include much information.
This is a continuation of my previous 2 questions:
http://answers.unity3d.com/questions/554933/how-could-i-create-a-book.html http://answers.unity3d.com/questions/555564/how-could-i-use-quads-to-make-a-book.html
Thanks for linking your previous questions. If this is the same question but more developed you should probably Close the old ones.
Flipping pages in a book is not a simple technical question. It embodies multiple technical problems and is highly depending on your design and goals. Here is a list of questions to consider:
How many pages?
What is the resolution of each texture?
What is the target platform: PC, Web, $$anonymous$$obile?
What are the operations that can be done on the book and what is the interface for each: Next page, previous page, close the book, go to specific page, last page, bring the book up, put the book away...?
How important is riffling (i.e. display of multiple pages when going to a page in the book)?
All these questions have a impact on the design. But Unity Answers is not designed for nor is the place to ask overarching design questions. As mentioned by me in your other question, Unity Forums with their discussion format is a much better fit. When you get down to specific questions, then UA is a great fit.
Answer by YoungDeveloper · Oct 15, 2013 at 05:35 PM
I would create a nice model of a book, and only one page (modeled from both sides). Then I would animate the page (one motion flip animation), uv unwrap both page sides as a seperate objects,both book sides as two separate objects and base book on third uv map. Now I'd write an array or textures, and add extra variables, like min, max and current page. So all i have to do now is create pages textures. And insert in the public array in the order they will be in the book.
When user flips the page, dynamically change textures from textures array to next array element. In reality,you will be flipping (playing animation) the same and only page model, but because of texture change it will look like you are flipping pages.
Thanks! For the first time in a while, I really understand what someone means. I completely understand the concept, but I'm not exactly sure how to do this.
It's called learning :) I think I explained everything pretty clearly. Start by modelling, unwrapping, texturing, animating then scripting.
Follow this Question
Related Questions
How could I create a book? 6 Answers
how to add material component to an Animate GUI script 1 Answer
How do I Rotate a Skybox's Material 4 Answers
Editing buttons created in 'for' loop. 0 Answers
Am i using good the array ? 0 Answers