3D for GML: Full pitch

From ENIGMA
Jump to navigation Jump to search

23.1 Creating full pitch

If you take a good look at the previous tutorial on Bullet paths, you will find that the character can not look up or down all the way. The pitch of the character’s view is limited because the following line is used in the script dra_Camera:

zt=zf-sin(degtorad(zdirection));     //z to look to (with z direction)

A quick fix is to replace this line by:

zt=zf-tan(degtorad(zdirection));

This will result in a character that can look straight up and down. As you can see, we’re using tangent in stead of the usual sine.

23.2 Limiting the pitch

There is a slight drawback to using tangent in thisway which can be bypassed by adding this line to the scr_Mouselookscript:

//limit z
if zdirection<-89 then {zdirection=-89;} else if zdirection>89 then
{zdirection=89;}

What we are doing here is limiting the pitch (or zdirection) so that the character’s view will not flip. You can remove it, if you like,to see what results you would get without it. Though other solutions exist for this problem, this is a quick, easy and popular fix.


All rights reserved. Copyright © 2004 by John J.A.H. Weeren. Unauthorized use or reproduction, whole or in part, without written permission from the author is strictly prohibited. This page is part of the tutorial 3D For GML. Reproduced with permission. For more information, please see the talk page.