pointing camera to the player
Moderator: InsideQC Admins
8 posts
• Page 1 of 1
pointing camera to the player
Hello, im using a 3rd person camera and i've figured out how to make the camera follow the player when he moves. My problem is that the camera isn't pointing at the player, just following it, I dont know if you understand what I mean, the player is supposed to be centered on the screen...
Anyway, heres the part of the code which sets the position of the camera, relative to player's origin (is working):
And heres the part of the code which is supposed to make the camera point to the player: (not working)
self.owner.origin being the position of the player and view_org the camera's position. This should trace a line between both entities and then make the camera point at the player's origin, right?
Whatever, it's not pointing at it at all so I must be doing something wrong.. anyone has any idea how to fix it?
Thanks : )
Anyway, heres the part of the code which sets the position of the camera, relative to player's origin (is working):
- Code: Select all
makevectors(self.owner.angles); // i want it relative to players angle, not only players origin
view_org = self.owner.origin - v_forward * 90;
And heres the part of the code which is supposed to make the camera point to the player: (not working)
- Code: Select all
traceline (self.owner.origin, view_org, TRUE, self.owner);
view_org = trace_endpos;
self.owner.origin being the position of the player and view_org the camera's position. This should trace a line between both entities and then make the camera point at the player's origin, right?
Whatever, it's not pointing at it at all so I must be doing something wrong.. anyone has any idea how to fix it?
Thanks : )
- h4des
- Posts: 4
- Joined: Sun Feb 08, 2009 11:48 pm
- Location: Portugal
the code chunks you posted change nothing but a couple of server-side globals. A client won't see that.
so there must be some more code somewhere.
unless its csqc?... I'll assume its not.
change the player's angles field to something like:
player_ent.angles = vectoangles(viewer_origin - viewed_origin);
player_ent.fixangles = TRUE;
replace the various vars with the right values, and voila, or something
you might want to flip player_ent.angles_x...
so there must be some more code somewhere.
unless its csqc?... I'll assume its not.
change the player's angles field to something like:
player_ent.angles = vectoangles(viewer_origin - viewed_origin);
player_ent.fixangles = TRUE;
replace the various vars with the right values, and voila, or something
you might want to flip player_ent.angles_x...
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Spike wrote:the code chunks you posted change nothing but a couple of server-side globals. A client won't see that.
so there must be some more code somewhere.
unless its csqc?... I'll assume its not.
change the player's angles field to something like:
player_ent.angles = vectoangles(viewer_origin - viewed_origin);
player_ent.fixangles = TRUE;
replace the various vars with the right values, and voila, or something
you might want to flip player_ent.angles_x...
Im not at school right now so I cant test but, isn't that going to change the players angles in relation to the camera's origin?
I want the opposite because I have some functions that rotate the players Y-angle and the camera doesn't "update" when I'm doing that. Dont know if you get what I mean.
- h4des
- Posts: 4
- Joined: Sun Feb 08, 2009 11:48 pm
- Location: Portugal
You mean you want to separate the player's angles from the direction that they are looking in?
Yeah... Not gonna happen.
The client's view angle is a copy of their input angle.
The only way to properly separate them is to use CSQC.
Alternatively, you can do your own player angles ("alias +left \"impulse 100\"\n" style...) but that would mean you'd not be able to use the mouse.
Or there's the possibility of trying to monitor player angle changes and trying to compensate for the angle changes that echo from the fixangles.
Yeah... Not gonna happen.
The client's view angle is a copy of their input angle.
The only way to properly separate them is to use CSQC.
Alternatively, you can do your own player angles ("alias +left \"impulse 100\"\n" style...) but that would mean you'd not be able to use the mouse.
Or there's the possibility of trying to monitor player angle changes and trying to compensate for the angle changes that echo from the fixangles.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Spike wrote:You mean you want to separate the player's angles from the direction that they are looking in?
Yeah... Not gonna happen.
The client's view angle is a copy of their input angle.
The only way to properly separate them is to use CSQC.
Alternatively, you can do your own player angles ("alias +left "impulse 100"\n" style...) but that would mean you'd not be able to use the mouse.
Or there's the possibility of trying to monitor player angle changes and trying to compensate for the angle changes that echo from the fixangles.
Yes, thats what I want to do... I have an alias which is +move_left and what it does is that it changes the player angle.
The mouse isn't a problem as im planning to use a gamepad/keyboard for this game.
What should I do in CSQC? I guess it's something in the function CSQC_UpdateView(), right?
MauveBib wrote:Can't you writebyte the viewing angles?
How would that be done?
edit:
i figured out how to point the camera to the player and make it also follow it. My problem now is that once I press the key to rotate the player it then keeps rotating forever.
Is Quake auto-adjusting the player's angle regarding the camera's angle? If yes, how can I disable it? Because im changing the angles of both "manually".
- h4des
- Posts: 4
- Joined: Sun Feb 08, 2009 11:48 pm
- Location: Portugal
I am interested in how you got it to work.
I fixed the third person view in my engine but it isn't working right.
I want it to work like yours tho.
I tried messing with the player boundaries. I came up with nothing. My engine is also using the Game Pad.
I fixed the third person view in my engine but it isn't working right.
I want it to work like yours tho.
I tried messing with the player boundaries. I came up with nothing. My engine is also using the Game Pad.
- Team Xlink
- Posts: 368
- Joined: Thu Jun 25, 2009 4:45 am
- Location: Michigan
This seems like a simple chasecam for quakeC?
here's a crude example , (without clipping nor smoothing)
self is the camera, while
self.movetarget is the player that the camera is following.
called every frame of course.
edit: just noticed this thread was from March eek!
here's a crude example , (without clipping nor smoothing)
self is the camera, while
self.movetarget is the player that the camera is following.
- Code: Select all
void () update_camera_position =
{
local vector pos;
local vector angle;
angle = self.movetarget.v_angle;
angle_z = 0;
makevectors(angle);
pos = self.movetarget.origin;
pos = pos + 50 * v_up; //move the camera up over his head
pos = pos - 100 * v_forward; //move camera back 100 units
setorigin(self, pos);
self.angles = angle;
self.v_angle = angle;
self.fixangle = TRUE;
};
called every frame of course.
edit: just noticed this thread was from March eek!
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
