Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Akow, TipmyPip, tomaslolo), 788 guests, and 11 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: Car Physics [Re: Helghast] #88664
09/18/06 20:51
09/18/06 20:51
Joined: Mar 2005
Posts: 134
J
jeffmorris Offline OP
Member
jeffmorris  Offline OP
Member
J

Joined: Mar 2005
Posts: 134
Dennis, Thanks for the updated code but I control the car as if it was a R/C car and the car spins out of control. I think that the values need to be reduced in the while loop of function control. I wish to be inside the car when I drive the car.

Re: Car Physics [Re: jeffmorris] #88665
09/19/06 15:49
09/19/06 15:49
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
should change that yourself, i just setup a very simple car control.
nothing fancy, could try to lower the speed of rotation and speedup, just change it to your needs.

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Car Physics [Re: jeffmorris] #88666
09/19/06 23:38
09/19/06 23:38
Joined: May 2006
Posts: 398
Bot190 Offline
Senior Member
Bot190  Offline
Senior Member

Joined: May 2006
Posts: 398
hes stuborn to i asked about camera code and he wouldn't help me.


ps. I still haven't figured it out!


Wait, there isn't a "Make My Game Now" button?
Re: Car Physics [Re: Bot190] #88667
09/20/06 08:23
09/20/06 08:23
Joined: Oct 2005
Posts: 26
B
Bananatech Offline
Newbie
Bananatech  Offline
Newbie
B

Joined: Oct 2005
Posts: 26
Code:
  
//Put this in "function main" Simple_TestphCar_Camera();
//"Function Simple_TestphCar_Camera" needs to be below the entity* car;

Function Simple_TestphCar_Camera
{
while(!car){wait(1);}
var cam_ang[3];
var cam_dist=50;
var Adjust_Pan = 0;
var Adjust_Roll = 0;

camera.arc=52;
camera.clip_near=24;
camera.clip_far=24000;

cam_ang.pan=180;
cam_ang.tilt=30;
cam_ang.roll=0;

while(1)
{
camera.x = car.x - 350 * cos(car.pan + Adjust_Pan);
camera.y = car.y - 350 * sin(car.pan + Adjust_Pan);
camera.z = car.z + 100;
camera.pan = car.pan + Adjust_Pan;
camera.tilt = -10;
camera.roll = car.roll + Adjust_Roll ;
wait(1);
}
}



Have fun )

Re: Car Physics [Re: Bot190] #88668
09/20/06 09:42
09/20/06 09:42
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
Quote:

hes stuborn to i asked about camera code and he wouldn't help me.
ps. I still haven't figured it out!




thanks, i'll share another car physics code next time...

I'm not stubborn, i just dont have that much time as i used to.
besides you'll learn a lot more from doinf it yourself then making a game out of downloaded scripts!

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Car Physics [Re: Helghast] #88669
09/20/06 09:50
09/20/06 09:50
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
im too good for this community.
I took some of my old code, and put it together in a camera script with collision.

Now i dont wanna hear im stubborn anymore!
Code:
 
entity* car;

//Environment Defines
var earth_gravity[3] = 0,0, -887;

var camera_distance = 400;//change to whatever
var temporary_distance;
var distance_traced;

function avoid_obstacles()
{
car.skill42 = camera_distance;
trace_mode = ignore_me + ignore_passable;
vec_set(temporary_distance.x, camera.x);
temporary_distance.z -= 50;
distance_traced = c_trace(car.x, temporary_distance.x, ignore_models);
if (distance_traced == 0) // Nothing in the way?
{
if (camera_distance < car.skill42)
{
camera_distance += 1;
}
}
else
{
distance_traced -= 5;
camera.x = car.x - distance_traced * cos(camera.pan); // place the camera behind the player
camera.y = car.y - distance_traced * sin(camera.pan); // at the new distance given by distance_traced
}
}

//Put this in "function main" Simple_TestphCar_Camera();
//"Function Simple_TestphCar_Camera" needs to be below the entity* car;
Function Simple_TestphCar_Camera
{
var vCameraPos_Angle; // Angle the camera is at in relation to the cars angle

while (!car) {wait (1);} // wait for car to be created
vCameraPos_Angle = car.pan; // Start behind
// Follow behind the car
while(1)
{
while(freeze_mode == 1){wait(1);}
// Find the difference in the cameras heading compared to the cars heading
temp.x = ang (car.pan - camera.pan);
temp.x = clamp (temp.x, -3.5 * time, 3.5 * time);
vCameraPos_Angle += temp.x; // Adjust the viewing angle

// Position camera behind car from its viewing angle
temp.x = -450;
temp.y = 0;
temp.z = 100;
vec_rotate (temp, vector(vCameraPos_Angle, 0, 0));
vec_add (temp, car.x);
vec_set (camera.x, temp.x);

// face the car
vec_set (temp, car.x);
vec_sub (temp.x, camera.x);
vec_to_angle (camera.pan, temp.x);

avoid_obstacles();
wait (1);
}
}

action physics_ent
{
car = me;
phent_settype(my, PH_RIGID, PH_BOX);
ph_setgravity( earth_gravity );
phent_setmass(my, 7, PH_BOX);
phent_setfriction(my,20);
phent_setelasticity(my, 25, 1);
phent_setdamping(my, 30, 15);

control();
}

function control
{
var velocity;
var velocity3[3];
while(1)
{
phent_getvelocity(my, velocity3, nullvector);
velocity = vec_length(velocity3);

if(key_w == 1){vec_set(temp.x, my); vec_normalize(temp, 5000); phent_addforcelocal(my, temp, nullvector);}
if(key_s == 1){vec_set(temp.x, my); vec_normalize(temp, -2500); phent_addforcelocal(my, temp, nullvector);}
if(key_a == 1 && velocity > 60){phent_addtorqueglobal (my, vector(0, 0, 200));}
if(key_d == 1 && velocity > 60){phent_addtorqueglobal (my, vector(0, 0, -200));}
wait(1);
}
}

function main
{
video_switch(7, 32, 2);

fps_max = 60;

level_load("nascar_test.wmb");
wait(5);

Simple_TestphCar_Camera();
}



youre all welcome

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Car Physics [Re: Helghast] #88670
09/20/06 10:47
09/20/06 10:47
Joined: May 2006
Posts: 398
Bot190 Offline
Senior Member
Bot190  Offline
Senior Member

Joined: May 2006
Posts: 398
sorry. i didn't mean to hurt your fellings. thxs it works perfectly.


Last edited by bot190; 09/20/06 10:56.

Wait, there isn't a "Make My Game Now" button?
Re: Car Physics [Re: Bot190] #88671
09/22/06 01:21
09/22/06 01:21
Joined: Oct 2003
Posts: 2,628
IL,US
FeiHongJr Offline
Expert
FeiHongJr  Offline
Expert

Joined: Oct 2003
Posts: 2,628
IL,US
Quote:

Now i dont wanna hear im stubborn anymore!




your so stubborn just kidding. It can just as easily be said that hes ungrateful prehaps even easier. Thanks for everything


http://www.freewebs.com/otama_syndicate/index.htm - Each master to his own technique.

- Not me said the bee, Nor I said the fly.
Re: Car Physics [Re: FeiHongJr] #88672
09/22/06 15:43
09/22/06 15:43
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline
Expert
FoxHound  Offline
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
I think some people need to shut their pie hole and right their own damn code. Not like it's hard to find a third person camera on this fourm, I think i've written about 5 in responce to nicely asked posts.

In addition to all this there already is a car code on the download page, complte with camera.


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Re: Car Physics [Re: FoxHound] #88673
09/22/06 22:56
09/22/06 22:56
Joined: May 2006
Posts: 398
Bot190 Offline
Senior Member
Bot190  Offline
Senior Member

Joined: May 2006
Posts: 398
mm... if you have pro. not every one is rich you know. don't get made at me though im not trying to be mean.


Wait, there isn't a "Make My Game Now" button?
Page 2 of 3 1 2 3

Moderated by  HeelX, Spirit 

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