#### Archived

This topic is now archived and is closed to further replies.

# movement with third person cam view

This topic is 6027 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

yes i wanna know if someone can help me for doing a first person cam view with velocity updating each rotation how to do that se what i do : Tcamera = class position:Tvector; velocity:Tvector; view:Tvector; upvector:Tvector; rayon:glfloat; constructor Create; procedure positioncamera(posx:glfloat;posy:glfloat;posz:glfloat;viewx:glfloat; viewy:glfloat;viewz:glfloat;upx:glfloat;upy:glfloat;upz:glfloat); procedure mov(speed:glfloat); procedure rotate(dir:glfloat); procedure rotatearound(joueur:Tvector;dir:glfloat); end; implementation constructor Tcamera.Create; begin inherited Create; with position do begin x:=0; y:=0; z:=0; end; with view do begin x:=0; y:=1.0; z:=0.5; end; with upvector do begin x:=0; y:=1; z:=0; end; rayon:=5; with velocity do begin x:=0; y:=0; z:=-2; end; end; procedure Tcamera.positioncamera(posx:glfloat;posy:glfloat;posz:glfloat;viewx:glfloat; viewy:glfloat;viewz:glfloat;upx:glfloat;upy:glfloat;upz:glfloat); begin with position do begin x:=posx; y:=posy; z:=posz; end; with view do begin x:=viewx; y:=viewy; z:=viewz; end; with upvector do begin x:=upx; y:=upy; z:=upz; end; end; procedure Tcamera.mov(speed:glfloat); begin position.x:=position.x+velocity.x*speed; position.z:=position.z+velocity.z*speed; view.x:=view.x+velocity.x*speed; view.z:=view.z+velocity.z*speed; end; procedure Tcamera.rotatearound(joueur:Tvector;dir:glfloat); var aux:Tvector; begin with aux do begin x:=position.x-joueur.x; z:=position.z-joueur.z; end; position.z:=(joueur.z+sin(dir)*aux.x+cos(dir)*aux.z); position.x:=(joueur.x+cos(dir)*aux.x-sin(dir)*aux.z); velocity.z:=(sin(dir)*velocity.x+cos(dir)*velocity.z); velocity.x:=(cos(dir)*velocity.x-sin(dir)*velocity.z); velocity.y:=velocity.y; end; procedure Tcamera.rotate(dir:glfloat); var aux:Tvector; begin with aux do begin x:=view.x-position.x; y:=view.y-position.y; z:=view.z-position.z; end; view.z:=(position.z+sin(dir)*aux.x+cos(dir)*aux.z); view.x:=(position.x+cos(dir)*aux.x-sin(dir)*aux.z); velocity.z:=(sin(dir)*velocity.x)+(cos(dir)*velocity.z); velocity.x:=(cos(dir)*velocity.x)-(sin(dir)*velocity.z); end; the fonction that i used is rotate around . to make my rotation but the velocity don''t walk. because when i do a lot of rotation it tend to 0 unit. there is no more velocity after 10 rotation for exmple so i don''t still move that my problem . please help me please help me end. love and peace

##### Share on other sites
what do you actually want? first person (as you say in your post) or third person (as you say in your thread´s topic) ??

##### Share on other sites
third person sorry like in tomb raider can you help me please./
if i post it here it''s because i think that it''s the best forum for this problem

love and peace

##### Share on other sites
sorry i´ve never done a third person view.

##### Share on other sites
so explain me how to the view like in tom raider please.

love and peace

##### Share on other sites
I don''t see what you''re going to have your velocity for (read in the other forums).

If the player-object is positioned at (x, y, z) with yaw (a) and pitch (b), the camera must be put at (x - CAM_DIST * sin(a), y - CAM_DIST * sin(b), z - CAM_DIST * cos(a + 180)), or alike. CAM_DIST is the shortest distance we can put the camera from the player object without getting any polygons inbetween. A simple ray-trace check is everything you need.

##### Share on other sites
but i need this velocity to perform collision detection.
here the problem is that when i turn i have to have my velocity vector réoriented in the good direction and i can''t that why.
so i wanna know how to have my velocity vector in the good orientation to perform collision detection.

love and peace

##### Share on other sites
I see that you have one vector for position and a vector for the view. Due to possible errors in calcs, I give you the advice to calculate the view vector from the position and view vector.

The velocity vector moves the position. This is calculated from the current state of the view, user input and perhaps some additional stuff. Is this the major problem?

##### Share on other sites
i resolve my problem now there was full things that i did not anderstand but now it is thnaks

love and peace

1. 1
Rutin
47
2. 2
3. 3
4. 4
5. 5

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632994
• Total Posts
3009769
• ### Who's Online (See full list)

There are no registered users currently online

×