Interactive animated page turning

I’ve begun working on code to make a 3D book that turns pages when clicked.

I’m trying to make the book pages instantiate physics-based pages with a hinge joint that rotate toward the other side of the book. I want them to disappear when they reach the other side of the book (180 degree rotation). I’m somewhat baffled by Quaternions. What’s the best way to determine when an instantiated page has rotated 180?

At the tips of each page you could perhaps put a collider object or a trigger

And then place a Static Rigid Body on the flat book it self.

On the Rigidbody object place a Shader script that fades the instantiated page when it collides …Not sure It’s the best way to tackle it but thats how I would deal with it…

Thanks for your suggestions!

I thought of doing it with colliders too and I might end up doing it that way but I didn’t want to give up learning how to use quaternions before trying it.

I made a script called PageVanish.js that I put on the instantiated page prefab:

function Update () {
	// debug(transform.rotation.eulerAngles.x);
	// debugging showed that x values start at 90 and go down till they reach 0 then from 360 and down to 270 again
	
	// if rotation is between 91 and 270 degrees 
	if ( transform.rotation.eulerAngles.x <= 275  transform.rotation.eulerAngles.x >= 91  ) {
		// map the prefab page's texture to the page surface beneath it
		
		// the page vanishes
		Destroy( gameObject );	
	}
}

Next I’ll probably want to add the fade code and dynamic page and book surface texture rendering.

don’t use Destroy gameObject in the code might throw up null errors I would suggest

render.enabled.active = false;[/code]

to give it a polished feel i still think you should do a fade with a shader on the page instead of it just vanishing very unsubtle…

also my suggestion might not work so dont take it as Gospel… :wink:

This is what I mae so far.

207555–7643–$booktest_971.zip (1.33 MB)

dude if you can be Arsed post a unity webplayer…I will check it out … I never download unless I have to… :wink: