Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,561 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Very big problem with camera! #324388
05/20/10 15:50
05/20/10 15:50
Joined: May 2010
Posts: 22
X
XardasBeginer Offline OP
Newbie
XardasBeginer  Offline OP
Newbie
X

Joined: May 2010
Posts: 22
Good morning. I have problem with camera. My code is:
#include <default.c>;
#include <acknex.h>;


//zmienne itd.
var constr_front_left;
var constr_front_right;

var constr_back_left;
var constr_back_right;

VECTOR mom_speed;
var max_angle;
var stear_contr;

var max_speed = 1500;
var ang_force;
var speed_contr;

VECTOR* vec_gravity = {x = 0; y = 0; z = -1800;}

ENTITY* chassis;




function wheel_physics_init()
{
set (my, SHADOW);

phent_settype (my, PH_RIGID, PH_SPHERE);
phent_setmass (my, 30, PH_SPHERE);
phent_setgroup (my, 2);

phent_setfriction (my, 100);
phent_setdamping (my, 20, 20);
phent_setelasticity (my, 0, 100);
}

///Ko&#322;a przednie
function front_tyre_left()
{
wheel_physics_init();

constr_front_left = phcon_add (PH_WHEEL, chassis, my);
phcon_setparams1 (constr_front_left, my.x, vector (0,0,1), nullvector);
phcon_setparams2 (constr_front_left, nullvector, nullvector, nullvector);
}

function front_tyre_right()
{
wheel_physics_init();

constr_front_right = phcon_add (PH_WHEEL, chassis, my);
phcon_setparams1 (constr_front_right, my.x, vector (0,0,1), nullvector);
phcon_setparams2 (constr_front_right, nullvector, nullvector, nullvector);
}


///Ko&#322;a tylne
function back_tyre_left()
{
wheel_physics_init();

constr_back_left = phcon_add (PH_WHEEL, chassis, my);
phcon_setparams1 (constr_back_left, my.x, nullvector, vector (0,1,0));
phcon_setparams2 (constr_back_left, nullvector, nullvector, nullvector);
}

function back_tyre_right()
{
wheel_physics_init();

constr_back_right = phcon_add (PH_WHEEL, chassis, my);
phcon_setparams1 (constr_back_right, my.x, nullvector, vector (0,1,0));
phcon_setparams2 (constr_back_right, nullvector, nullvector, nullvector);
}


function chassis_init()
{
chassis = my;
set (chassis, SHADOW);

//Zmienne fizyki
phent_settype (chassis, PH_RIGID, PH_BOX); // rigid and box as collision hull
phent_setmass (chassis, 15, PH_BOX); // lighter than wheels to avoid tilt
phent_setgroup (chassis, 2); // all parts of the car in one group --> no collision

phent_setfriction (chassis, 20);
phent_setdamping (chassis, 5, 5);
phent_setelasticity (chassis, 10, 100); // only little bouncing


//zainicjuj ko&#322;a auta
//tylne
ent_create ("car_tyre_left.mdl", vector (chassis.x - 65, chassis.y - 45, chassis.z - 20), back_tyre_left);
ent_create ("car_tyre_right.mdl", vector (chassis.x - 65, chassis.y + 45, chassis.z - 20), back_tyre_right);
//przednie
ent_create ("car_tyre_left.mdl", vector (chassis.x + 65, chassis.y - 45, chassis.z - 20), front_tyre_left);
ent_create ("car_tyre_right.mdl", vector (chassis.x + 65, chassis.y + 45, chassis.z - 20), front_tyre_right);
wait(1);
}


void main()
{
level_load ("map.hmp");
wait(2);
//Auto

ent_create ("chassis.mdl", vector (0,0, 100), chassis_init);
video_set (1024, 768, 0, 0); //ustaw 1024x768 window mode
wait(2);
vec_set(camera.x,vector(-150,0,50));
vec_set (camera.x,vector(-500,0,0));
vec_rotate (camera.x,camera.pan);
vec_add (camera.x,chassis.x);


//Zainicjuj system fizyczny
ph_setgravity (vec_gravity);

ph_fps_max_lock = 1000;//500


///Szybko&#347;&#263; i skr&#281;t
while (1)
{
///Skr&#281;canie
stear_contr = (key_d - key_a);//d = 1, a = -1, a & d = 0
max_angle += stear_contr * 3 * time_step;
max_angle = clamp (max_angle, -30, 30);

if (stear_contr != 0)
{
phcon_setparams2 (constr_front_left, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0));
phcon_setparams2 (constr_front_right, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0));
}

else
{
max_angle = max_angle * (1 - (0.25 * time_step));
if (abs(max_angle) < 1)
max_angle = 0;

phcon_setparams2 (constr_front_left, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0));
phcon_setparams2 (constr_front_right, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0));
}

///Pr&#281;dko&#347;&#263;
speed_contr = (key_w - key_s);//w = 1, s = -1, w & s = 0

ang_force = speed_contr * 1000 * time_step;


phcon_setmotor (constr_back_left, nullvector, vector(-ang_force, max_speed, 0), nullvector);
phcon_setmotor (constr_back_left, nullvector, vector(-ang_force, max_speed, 0), nullvector);

wait(1);

}
}


And, my camera DON'T follow this object "chassis"!!!
I'm compliling this in Lite-C, but i have got Gamestudio a7 30 days trial.

Oh, and please, don't write in German language

And, don't look for comments - it's in polish language laugh

Last edited by XardasBeginer; 05/20/10 15:51.
Re: Very big problem with camera! [Re: XardasBeginer] #324390
05/20/10 16:01
05/20/10 16:01
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
How is it supposed to follow the camera? You adjust the camera position one time. You need to put this in a loop if you want the camera to follow.


Always learn from history, to be sure you make the same mistakes again...
Re: Very big problem with camera! [Re: Uhrwerk] #324393
05/20/10 16:09
05/20/10 16:09
Joined: May 2010
Posts: 22
X
XardasBeginer Offline OP
Newbie
XardasBeginer  Offline OP
Newbie
X

Joined: May 2010
Posts: 22
mmmm, sorry, but i am very beginer programmer. When i add only "while(1)" before
vec_set(...) it's don't wor. Can You modify this code. Very Thank You

Re: Very big problem with camera! [Re: XardasBeginer] #324395
05/20/10 16:13
05/20/10 16:13
Joined: Sep 2009
Posts: 496
P
Progger Offline
Senior Member
Progger  Offline
Senior Member
P

Joined: Sep 2009
Posts: 496
try this maybe it works :
Code:
#include <default.c>;
#include <acknex.h>;


//zmienne itd.
var constr_front_left;
var constr_front_right;

var constr_back_left;
var constr_back_right;

VECTOR mom_speed;
var max_angle;
var stear_contr;

var max_speed = 1500;
var ang_force;
var speed_contr;

VECTOR* vec_gravity = {x = 0; y = 0; z = -1800;}

ENTITY* chassis;




function wheel_physics_init()
{
set (my, SHADOW);

phent_settype (my, PH_RIGID, PH_SPHERE);
phent_setmass (my, 30, PH_SPHERE);
phent_setgroup (my, 2);

phent_setfriction (my, 100);
phent_setdamping (my, 20, 20);
phent_setelasticity (my, 0, 100);
}

///Ko&#322;a przednie
function front_tyre_left()
{
wheel_physics_init();

constr_front_left = phcon_add (PH_WHEEL, chassis, my);
phcon_setparams1 (constr_front_left, my.x, vector (0,0,1), nullvector);
phcon_setparams2 (constr_front_left, nullvector, nullvector, nullvector);
}

function front_tyre_right()
{
wheel_physics_init();

constr_front_right = phcon_add (PH_WHEEL, chassis, my);
phcon_setparams1 (constr_front_right, my.x, vector (0,0,1), nullvector);
phcon_setparams2 (constr_front_right, nullvector, nullvector, nullvector);
}


///Ko&#322;a tylne
function back_tyre_left()
{
wheel_physics_init();

constr_back_left = phcon_add (PH_WHEEL, chassis, my);
phcon_setparams1 (constr_back_left, my.x, nullvector, vector (0,1,0));
phcon_setparams2 (constr_back_left, nullvector, nullvector, nullvector);
}

function back_tyre_right()
{
wheel_physics_init();

constr_back_right = phcon_add (PH_WHEEL, chassis, my);
phcon_setparams1 (constr_back_right, my.x, nullvector, vector (0,1,0));
phcon_setparams2 (constr_back_right, nullvector, nullvector, nullvector);
}


function chassis_init()
{
chassis = my;
set (chassis, SHADOW);

//Zmienne fizyki
phent_settype (chassis, PH_RIGID, PH_BOX); // rigid and box as collision hull
phent_setmass (chassis, 15, PH_BOX); // lighter than wheels to avoid tilt
phent_setgroup (chassis, 2); // all parts of the car in one group --> no collision

phent_setfriction (chassis, 20);
phent_setdamping (chassis, 5, 5);
phent_setelasticity (chassis, 10, 100); // only little bouncing


//zainicjuj ko&#322;a auta
//tylne
ent_create ("car_tyre_left.mdl", vector (chassis.x - 65, chassis.y - 45, chassis.z - 20), back_tyre_left);
ent_create ("car_tyre_right.mdl", vector (chassis.x - 65, chassis.y + 45, chassis.z - 20), back_tyre_right);
//przednie
ent_create ("car_tyre_left.mdl", vector (chassis.x + 65, chassis.y - 45, chassis.z - 20), front_tyre_left);
ent_create ("car_tyre_right.mdl", vector (chassis.x + 65, chassis.y + 45, chassis.z - 20), front_tyre_right);
wait(1);
}


void main()
{
level_load ("map.hmp");
wait(2);
//Auto

ent_create ("chassis.mdl", vector (0,0, 100), chassis_init);
video_set (1024, 768, 0, 0); //ustaw 1024x768 window mode
wait(2);



//Zainicjuj system fizyczny
ph_setgravity (vec_gravity);

ph_fps_max_lock = 1000;//500


///Szybko&#347;&#263; i skr&#281;t
while (1)
{
vec_set(camera.x,vector(-150,0,50));
vec_set (camera.x,vector(-500,0,0));
vec_rotate (camera.x,camera.pan);
vec_add (camera.x,chassis.x);
///Skr&#281;canie
stear_contr = (key_d - key_a);//d = 1, a = -1, a & d = 0
max_angle += stear_contr * 3 * time_step;
max_angle = clamp (max_angle, -30, 30);

if (stear_contr != 0)
{
phcon_setparams2 (constr_front_left, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0));
phcon_setparams2 (constr_front_right, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0));
}

else
{
max_angle = max_angle * (1 - (0.25 * time_step));
if (abs(max_angle) < 1)
max_angle = 0;

phcon_setparams2 (constr_front_left, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0));
phcon_setparams2 (constr_front_right, vector (max_angle, max_angle, 0), nullvector, vector (95000, 500, 0));
}

///Pr&#281;dko&#347;&#263;
speed_contr = (key_w - key_s);//w = 1, s = -1, w & s = 0

ang_force = speed_contr * 1000 * time_step;


phcon_setmotor (constr_back_left, nullvector, vector(-ang_force, max_speed, 0), nullvector);
phcon_setmotor (constr_back_left, nullvector, vector(-ang_force, max_speed, 0), nullvector);

wait(1);

}
}


WFG Progger laugh


asking is the best Way to get help laugh laugh laugh
Re: Very big problem with camera! [Re: Progger] #324397
05/20/10 16:19
05/20/10 16:19
Joined: May 2010
Posts: 22
X
XardasBeginer Offline OP
Newbie
XardasBeginer  Offline OP
Newbie
X

Joined: May 2010
Posts: 22
Yes, it works, but have more prblem - Its follow, but when i press "a" so car is turning, and camera don't follow back of car, but left. When i press "a" i see left side of car, not back.

Re: Very big problem with camera! [Re: XardasBeginer] #324401
05/20/10 16:50
05/20/10 16:50
Joined: Sep 2009
Posts: 496
P
Progger Offline
Senior Member
Progger  Offline
Senior Member
P

Joined: Sep 2009
Posts: 496
You can not fix that tongue
Just a little joke

change the old camera code with this code and put it in the while loop

camera.x = chassis.x - 200 * sin(chassis.pan);
camera.y = chassis.y - 200 * cos(chassis.pan);
camera.z=chassis.z+10
camera.pan = chassis.pan ; // face the player
WFG PRogger laugh

Last edited by Progger; 05/20/10 16:51.

asking is the best Way to get help laugh laugh laugh
Re: Very big problem with camera! [Re: Progger] #324403
05/20/10 16:56
05/20/10 16:56
Joined: May 2010
Posts: 22
X
XardasBeginer Offline OP
Newbie
XardasBeginer  Offline OP
Newbie
X

Joined: May 2010
Posts: 22
while (1)
{
camera.x = chassis.x - 200 * sin(chassis.pan);
camera.y = chassis.y - 200 * cos(chassis.pan);
camera.z= chassis.z+10
camera.pan = chassis.pan ; // face the player

With that code: ERROR in MAIN line 130 - syntax error

Line 130 - camera.pan = chassis.pan ; // face the player

Please, help me. Thank You

Re: Very big problem with camera! [Re: XardasBeginer] #324404
05/20/10 17:06
05/20/10 17:06
Joined: Sep 2009
Posts: 496
P
Progger Offline
Senior Member
Progger  Offline
Senior Member
P

Joined: Sep 2009
Posts: 496
yes im stupid
i forgot this ; at the end grin
here so its correct
camera.z= chassis.z+10;
WFG Progger laugh


asking is the best Way to get help laugh laugh laugh
Re: Very big problem with camera! [Re: XardasBeginer] #324405
05/20/10 17:07
05/20/10 17:07
Joined: Aug 2009
Posts: 1,438
Spain
painkiller Offline
Serious User
painkiller  Offline
Serious User

Joined: Aug 2009
Posts: 1,438
Spain
camera.x = chassis.x - 200 * sin(chassis.pan);
camera.y = chassis.y - 200 * cos(chassis.pan);
camera.z=chassis.z+10;
camera.pan = chassis.pan; // face the player


3D Gamestudio A8 Pro
AMD FX 8350 4.00 Ghz
16GB RAM
Gigabyte GeForce GTX 960 4GB
Re: Very big problem with camera! [Re: painkiller] #324414
05/20/10 18:14
05/20/10 18:14
Joined: May 2010
Posts: 22
X
XardasBeginer Offline OP
Newbie
XardasBeginer  Offline OP
Newbie
X

Joined: May 2010
Posts: 22
Alright, You help me, but it's not that. I wanna like camera like in some nfs. When car rotate, camera rotate with it. I want to have camera like in this game: http://www.youtube.com/watch?v=_Zn7mtvMOto&feature=player_embedded

Last edited by XardasBeginer; 05/21/10 12:20.
Page 1 of 2 1 2

Gamestudio download | 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