Need some help with camera work

Discuss programming in the QuakeC language.
Post Reply
vicious1988
Posts: 16
Joined: Sun Oct 12, 2008 10:14 pm

Need some help with camera work

Post by vicious1988 »

Long time no post. I'm needing some help with some camera code for an AC130. No, its not a CoD clone. But the idea did come while playing it.

Right now my problem is getting the camera to focus on a vector (currently 0,0,0), and rotate within constraints. The camera's yaw bugs out when it goes beyond +/-180 and automatically goes to the side of the constraint that is within the +/-180. I also lose control over pitch when I call fixangle=1.

Code: Select all

	self.movetype = MOVETYPE_FLY;
	self.torigin = '0 0 0'; // what to focus towards
	self.tvec = vectoangles(self.origin-self.torigin); 

	self.ty = self.tvec_y - 180;

// need to be within +/- 180
	if (self.ty < -180)
		self.ty + 360;
	if (self.ty > 180)
		self.ty - 360;
	
 // yaw constraints
	if (self.angles_y > self.ty + 80)
		self.angles_y = self.ty + 80;
	if (self.angles_y < self.ty - 80)
		self.angles_y = self.ty - 80;

// need to be within +/- 180
	if (self.angles_y > 180)
		self.angles_y - 360;
	if (self.angles_y < -180)
		self.angles_y + 360;

// pitch constraint
	if (self.angles_x > 0)
		self.angles_x = 0;

// debug output (heh, right)
	sprint(self,ftos(self.tvecy));
	sprint(self,"\n");
	sprint(self,ftos(self.anglesy));
	sprint(self,"\n");
	self.fixangle=1;
I'm calling this function in PostThink (tried in PreThink as well) only when the AC130 role is chosen. I already know its going to be something painfully obvious, practically shouting "RIGHT HERE!"

I'm also trying to determine the best way of moving the camera in a circle around the given vector since the camera is being used for aiming the armaments.
Post Reply