Page 1 of 1

camera pitch

Posted: Fri Feb 08, 2008 12:37 am
by darksmaster923
hey for
self.camera_pitch
what is it stored in? radians?

Re: camera pitch

Posted: Sat Feb 09, 2008 6:22 am
by darksmaster923
ok i made the script so that the gun stays on screen but

Code: Select all

	pos[ ()
	{
		camerapitchtemp = self.camera_pitch;
		if(self.camera_pitch > 0.4)
		{
			PositionToPawn("player",offsetX,offsetY+4,offsetZ+4,true,false);
		}
		else
		{
			if(self.camera_pitch > 0.3)
			{
				PositionToPawn("player",offsetX,offsetY+3,offsetZ+3,true,false);
			}
			else
			{
				if(self.camera_pitch > 0.2)
				{
					PositionToPawn("player",offsetX,offsetY+2,offsetZ+2,true,false);
				}
				else
				{
					if(self.camera_pitch > 0.1)
					{
						PositionToPawn("player",offsetX,offsetY+1,offsetZ+1,true,false);
					}
					else
					{
					PositionToPawn("player",offsetX,offsetY,offsetZ,true,false);
					}
				}
			}
		}
		self.ideal_yaw = self.player_yaw;
        	ChangeYaw(); 

		self.ideal_pitch = self.camera_pitch;	
		ChangePitch();
	} ]
is just ridiculous. any way to shorten or better idea?

Re: camera pitch

Posted: Sat Feb 09, 2008 12:31 pm
by Juutis
Basic mathematics:

Code: Select all

PositionToPawn("player",offsetX,offsetY*cos(-self.camera_pitch)+offsetZ*sin(-self.camera_pitch),offsetZ*cos(self.camera_pitch)+offsetY*sin(self.camera_pitch),true,false);
You may need to add or remove some minuses to get it right, though ('-self.camera_pitch' -> 'self.camera_pitch' and vice versa).

Re: camera pitch

Posted: Sat Feb 09, 2008 5:31 pm
by darksmaster923
tried all teh combos, doesnt seem to work, it just makes my arms fly forward

Re: camera pitch

Posted: Sat Feb 09, 2008 5:44 pm
by Juutis
Oh, I just realized it needs a little addition:

Code: Select all

PositionToPawn("player",offsetX,OFFSETY+offsetY*cos(-self.camera_pitch)+offsetZ*sin(-self.camera_pitch),offsetZ*cos(self.camera_pitch)+offsetY*sin(self.camera_pitch),true,false);
OFFSETY is the height of the camera from the player's origin. The camera height is defined in the camera.ini. So for example if camera.ini says: 'height = 50', you would set 'OFFSETY = 50'.
offsetY is the weapon's Y-offset from the camera.

Re: camera pitch

Posted: Sun Feb 10, 2008 2:54 am
by darksmaster923
didnt actually get it to work so i made this

Code: Select all

camerapitchtemp = self.camera_pitch*10;
PositionToPawn("player",offsetX,75+offsetY+camerapitchtemp,offsetZ+camerapitchtemp,true,false);
gud enough for my needs