Inside3D!
     

pointing camera to the player

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
h4des



Joined: 08 Feb 2009
Posts: 4
Location: Portugal

PostPosted: Mon Mar 30, 2009 11:04 pm    Post subject: pointing camera to the player Reply with quote

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):

Code:

   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:

   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 : )
Back to top
View user's profile Send private message MSN Messenger
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Mon Mar 30, 2009 11:40 pm    Post subject: Reply with quote

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...
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
h4des



Joined: 08 Feb 2009
Posts: 4
Location: Portugal

PostPosted: Tue Mar 31, 2009 11:54 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message MSN Messenger
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Tue Mar 31, 2009 12:45 pm    Post subject: Reply with quote

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.
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
MauveBib



Joined: 04 Nov 2004
Posts: 602

PostPosted: Tue Mar 31, 2009 12:55 pm    Post subject: Reply with quote

Can't you writebyte the viewing angles?
_________________
Apathy Now!
Back to top
View user's profile Send private message
h4des



Joined: 08 Feb 2009
Posts: 4
Location: Portugal

PostPosted: Tue Mar 31, 2009 4:23 pm    Post subject: Reply with quote

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".
Back to top
View user's profile Send private message MSN Messenger
Team Xlink



Joined: 25 Jun 2009
Posts: 320

PostPosted: Mon Jul 20, 2009 11:24 pm    Post subject: Reply with quote

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.
_________________
Anonymous wrote:
if it works, it works. if it doesn't, HAHAHA!
Back to top
View user's profile Send private message
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Tue Jul 21, 2009 3:01 pm    Post subject: Reply with quote

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.

Code:


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!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group