Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (ozgur, TipmyPip), 722 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Camera Problem #317171
03/29/10 20:06
03/29/10 20:06
Joined: Mar 2010
Posts: 15
O
Omighty Offline OP
Newbie
Omighty  Offline OP
Newbie
O

Joined: Mar 2010
Posts: 15
I can't seem to get the camera behind the player. But every thing else apart from the camera position works fine. At the moment the camera is facing the side of the player instead of it being behind the player.

This is the code that I use, is there something wrong?



function camera_follow(ENTITY* chrac)
{
while(1) {
vec_set(camera.x,vector(-250,-45,45)); // camera position relative to the player
vec_rotate(camera.x ,chrac.pan); // rotate the camera position with the player
vec_add(camera.x,chrac.x); // add player position
vec_set(camera.pan,vector( chrac.pan,-10,0)); // look in player direction, slighty down
wait(1);
}
}

action player_1() // control the player
{

camera_follow(my);


VECTOR vFeet;
vec_for_min(vFeet,my); // vFeet.z = distance from player origin to lowest vertex
my.STATE = 1;
var walk_speed = 0;
var stand_speed = 0;
var run_speed = 0;

while (1)
{
stand_speed += 2*time_step;
ent_animate(me,"Stand",stand_speed,ANM_CYCLE);

// state 1: walking ////////////////////////////////////////////
if (key_cuu)
{
// rotate the entity with the arrow keys
my.pan += (key_cul-key_cur)*5*time_step;

// move the entity forward/backward with the arrow keys
var distance = (key_cuu-key_cud)*5*time_step;
c_move(me, vector(distance,0,0), NULL, GLIDE);

// animate the entity
walk_speed += 1.5*distance;
ent_animate(me,"Walk",walk_speed,ANM_CYCLE);

// adjust entity to the ground height, using a downwards trace
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
my.z = hit.z - vFeet.z; // always place player's feet on the ground


}

wait(1);
}

}


function main()
{
video_mode = 7; // 800x600 pixels
level_load ("terrain.wmb");
ent_create("MainCharacterBonesAtt.mdl", vector(-3072, 1741, -97), player_1);
wait (2);


}


Please help thanks

Re: Camera Problem [Re: Omighty] #317175
03/29/10 20:35
03/29/10 20:35
Joined: Sep 2009
Posts: 496
P
Progger Offline
Senior Member
Progger  Offline
Senior Member
P

Joined: Sep 2009
Posts: 496
what about
camera.x=chrac.x-300*cos(chrac.pan);
camera.y=chrac.y-300*sin(chrac.pan;
camera.z=chrac.z+5;
camera.pan=chrac.pan;

I hope that helps (:
Put this in the function:

Code:
function camera_follow(ENTITY* chrac)
{
 while(1) 
 { 
  camera.x=chrac.x-300*cos(chrac.pan);
  camera.y=chrac.y-300*sin(chrac.pan;
  camera.z=chrac.z+5;
  camera.pan=chrac.pan;
  wait(1);
 }
}




WFG Progger

Last edited by Progger; 03/29/10 20:39.

asking is the best Way to get help laugh laugh laugh
Re: Camera Problem [Re: Progger] #317291
03/30/10 13:03
03/30/10 13:03
Joined: Mar 2010
Posts: 15
O
Omighty Offline OP
Newbie
Omighty  Offline OP
Newbie
O

Joined: Mar 2010
Posts: 15
Progger thanks for the suggestion, but it still didn't work. The camera is still facing the right side of the player. Do I have to change something to the model in the med software?

Re: Camera Problem [Re: Omighty] #317292
03/30/10 13:04
03/30/10 13:04
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
the point were the camera should look should be the origin in med for the model

Re: Camera Problem [Re: Rei_Ayanami] #317298
03/30/10 13:23
03/30/10 13:23
Joined: Sep 2009
Posts: 496
P
Progger Offline
Senior Member
Progger  Offline
Senior Member
P

Joined: Sep 2009
Posts: 496
if you watch the side try camera.pan=chrac.pan-90 or try other values there
Hope that helps but check the orgin of the model like Rei_Ayanami said (:
WFG Progger


asking is the best Way to get help laugh laugh laugh
Re: Camera Problem [Re: Progger] #317339
03/30/10 16:59
03/30/10 16:59
Joined: Mar 2010
Posts: 15
O
Omighty Offline OP
Newbie
Omighty  Offline OP
Newbie
O

Joined: Mar 2010
Posts: 15
hi guy thanks for the help. I manage to fix it by changing the camera position and camera rotation
it was like this

function camera_follow(ENTITY* chrac)
{
while(1) {
vec_set(camera.x,vector(-250,-45,45)); // camera position relative to the player
vec_rotate(camera.x ,chrac.pan); // rotate the camera position with the player
vec_add(camera.x,chrac.x); // add player position
vec_set(camera.pan,vector( chrac.pan,-10,0)); // look in player direction, slighty down
wait(1);
}
}

now it looks this


void camera_follow(ENTITY* chrac)
{
while(1)
{
vec_set(camera.x,vector(-40,250,50)); // camera position relative to the player
vec_rotate(camera.x ,chrac.pan); // rotate the camera position with the player
vec_add(camera.x,chrac.x); // add player position
vec_set(camera.pan,vector( chrac.pan - 90,-10,0)); // look in player direction, slighty down
//camera.x=chrac.x-300*cos(chrac.pan);
//camera.y=chrac.y-300*sin(chrac.pan);
//camera.z=chrac.z+20;
//camera.pan=chrac.pan;

wait(1);
}

Progger i dint use your code grin. But it help me a lot thanks again.
Rei_Ayanami you were right about the origin. my player was facing the wrong way in med software.

Thanks guys GOD BLESS grin


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1