restricting range for looking up / down?
restricting range for looking up / down?
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?
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?
-
- Posts: 2126
- Joined: Sat Nov 25, 2006 1:49 pm
Re: restricting range for looking up / down?
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)
Re: restricting range for looking up / down?
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.
its the only one who works good for me.
I want basicially make a chasecam like in the newer Resident Evil games.
Re: restricting range for looking up / down?
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.
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.
Re: restricting range for looking up / down?
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
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
Re: restricting range for looking up / down?
Which ones do you know?drm_wayne wrote:I wonder why nobody did a good 3rd person cam already for quake xD
Re: restricting range for looking up / down?
This one is good too:mankrip wrote:Which ones do you know?drm_wayne wrote:I wonder why nobody did a good 3rd person cam already for quake xD
(from Rob Albin)
ftp://ftp.fu-berlin.de/pc/games/idgames ... asecam.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.
Re: restricting range for looking up / down?
here's a rough snippet of what i use to update the camera when chase-camming someone...
.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?
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);
};
you can then condition angle to be within a certain degree..
though for singleplayer a decent chase_active in the engine should suffice?
Re: restricting range for looking up / down?
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
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
Re: restricting range for looking up / down?
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.
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.
Re: restricting range for looking up / down?
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
EDIT: Nevermind, its still there, it just seems to "spawn" later lol