Forum

restricting range for looking up / down?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

restricting range for looking up / down?

Postby drm_wayne » Thu Apr 18, 2013 3:10 pm

hey,

i recently created a 3rd person chasecam, but i need to know how i can restrict the player too look up / down so you cant look
inside the model and directly to the ceiling /floor...

How can i do that?
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: restricting range for looking up / down?

Postby frag.machine » Thu Apr 18, 2013 4:23 pm

It depends. Are you using chase_active = 1 or did you implement a chasecam entity ?
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: restricting range for looking up / down?

Postby drm_wayne » Thu Apr 18, 2013 5:05 pm

its based on the enders scratch qc chasecam from the tutorials section :)
its the only one who works good for me.

I want basicially make a chasecam like in the newer Resident Evil games.
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: restricting range for looking up / down?

Postby Spike » Thu Apr 18, 2013 9:03 pm

most chasecam games seem to just make the player transparent if the camera comes too close.
In which case, check the distance and update the player's .alpha value when you move the camera.
doing it inside customizeentityforclient is a better choice if you want multiplayer to work, of course, but this is an extension which might not be available to you. do it in both placeas, and it'll work in multiplayer in engines that support the extension, without crashing engines that don't - it'll just look goofy in those, but hey, at least singleplayer will work okay!

you'll also need to ensure that the camera does not get within the near-clip-distance of walls. this is typically 4qu. sadly there is no mechanism that allows you to traceline with that precision however.
DP_QC_GETSURFACE can be used to find if there's a wall nearby, but its a real pain when doors etc are involved, it is possible though.

if you just want to clamp the player's view pitch range, cl_minpitch or cl_maxpitch work for some engines, or pq_minpitch/pq_maxpitch in proquake, or "serverinfo minpitch -30" for most quakeworld clients (where extened pitch ranges are considered a cheat).
because things would be boring if there was only one standard.

or you can use svc_setangles to force the angle to some other value. this sucks though. you can change the user's m_pitch cvar to 0, which will prevent the user from being able to change pitch angle with the mouse, which means you won't end up having to spam it endlessly, which can only be a good thing.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: restricting range for looking up / down?

Postby drm_wayne » Fri Apr 19, 2013 11:57 am

thanks, cl_minpitch and cl_maxpitch does the job...
And yeah, its currently only for a small singleplayer test, it currently feels like the 3rd person view
from fallout3..

I wonder why nobody did a good 3rd person cam already for quake xD
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: restricting range for looking up / down?

Postby mankrip » Fri Apr 19, 2013 2:02 pm

drm_wayne wrote:I wonder why nobody did a good 3rd person cam already for quake xD

Which ones do you know?
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Re: restricting range for looking up / down?

Postby drm_wayne » Fri Apr 19, 2013 4:06 pm

mankrip wrote:
drm_wayne wrote:I wonder why nobody did a good 3rd person cam already for quake xD

Which ones do you know?


This one is good too:
(from Rob Albin)
ftp://ftp.fu-berlin.de/pc/games/idgames2/quakec/misc/chasecam.zip

The Hack n Slash has a nice chasecam too:
http://hack-and-slash.sourceforge.net/hands/index.html

The "Survival Horror" DP mod has a nice one too, but sadly the author didnt want to give out
the sources (download says source included, but its not...)

http://chrisjpage.com/?page_id=75

The last one is very nice, but i think it uses many DP only features.
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: restricting range for looking up / down?

Postby r00k » Fri Apr 19, 2013 4:46 pm

here's a rough snippet of what i use to update the camera when chase-camming someone...
Code: Select all
void () observer_set_chase_position =
{
   local vector    pos, desired_angle, angle;
   local float      dist;
      
   if (time < self.otime)
      return;
   
   self.otime = self.otime + 0.01;

   angle_x = self.movetarget.v_angle_x;
   angle_y = self.movetarget.v_angle_y;
   angle_z = 0;
   
   makevectors(angle);
   pos = self.movetarget.origin;

   //Trace back 1st
   traceline(pos, pos - 100 * v_forward, TRUE, self.movetarget);
   pos = pos - (trace_fraction * 85) * v_forward;

   //then trace up
   traceline(pos, pos + 32 * v_up, TRUE, self.movetarget);
   pos = pos + (trace_fraction * 22) * v_up;
   
   traceline (self.origin, self.movetarget.origin, TRUE, self.movetarget);

   if (trace_fraction != 1) // View blocked, reset.
   {
      setorigin(self, pos);
   }
   else //Tethered by velocity to our cam target, hopefully a more fluid chase cam.
   {
      dist = vlen (self.origin - self.movetarget.origin); //How far are we from the target

      if ((dist < 100) || (dist > 400)) //Reset if out of bounds
      {
         setorigin(self, pos);
      }
      else
      {
         desired_angle = angles_bestaim (self.origin, pos);   
         makevectors(desired_angle);
         self.velocity = ((dist / 100) * 400) * v_forward;
         angle = angles_bestaim (self.origin, self.movetarget.origin);   
      }
   }

   angles_fixangle (angle);
};


.movetarget is the entity (player) i am tracking. The angle is forced though it could be angle = self.v_angle;
you can then condition angle to be within a certain degree..


though for singleplayer a decent chase_active in the engine should suffice?
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Re: restricting range for looking up / down?

Postby drm_wayne » Sun Apr 21, 2013 4:23 pm

The other problem with the cam is you can see thru walls....
I wonder if it can be fixed with a traceline code stopping the cam go thru walls??

Its this: http://inside3d.com/showtutorial.php?id=109
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: restricting range for looking up / down?

Postby r00k » Mon Apr 22, 2013 3:47 pm

my code above is 99% accurate in the manner of blocking the camera against walls.
it also kind of acts like a tethered balloon by lagging behind the player based on a fixed velocity.
Yet will move faster towards the player, the further away, or comlpetely reset to the base (back 100, up 32) if the
camera can not see the player at all.
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Re: restricting range for looking up / down?

Postby drm_wayne » Tue Apr 23, 2013 3:37 pm

i wonder, when i save and load a game the chasecam is gone??

EDIT: Nevermind, its still there, it just seems to "spawn" later lol :P
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest