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 (), 16,643 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
how to change car position? #367579
04/14/11 22:34
04/14/11 22:34
Joined: Dec 2010
Posts: 9
S
sbaya Offline OP
Newbie
sbaya  Offline OP
Newbie
S

Joined: Dec 2010
Posts: 9
Hi, i am using 3dgs commercial , i saw the code "knights_on_wheels" in the samples of the 3dgs
.................................................................................................................................................................
code:
#include <acknex.h>
#include <level.c> // add splash screen and terrain placement functions
#include <camera.c> // add a third person camera
#include <car.c> // add a car action
#include <car_props.c> // add a car speedometer

#define NUM_PLANTS 300

TEXT* txtHelp =
{
font = "Arial#15bi";
string("Cursor keys to control car");
string("Mouse wheel to zoom");
string("[Space] Brake | [H] Horn | [L] Kick toppled car");
string("[C] Toggle camera | [F1]..[F6] Camera modes");
flags = SHOW;
}

function quit() { sys_exit(NULL); }

action knight_on_wheels()
{
set(my,SHADOW);
// play with those parameters
my.car_maxSpeed = 80;
my.car_maxTorque = 350;
my.car_maxSteer = 30;
my.car_spsSpring = 150;
my.car_spsDamper = 30;
my.car_massOffset = -60;
my.car_frictionLatR = 150;
// wheel positions can be taken from the MED status line:
my.car_wheel_fx = 23.5;
my.car_wheel_rx = -26;
my.car_wheel_fy = 21;
my.car_wheel_ry = 21;
my.car_wheel_fz = -10;
my.car_wheel_rz = -11;
my.car_spsWay = 7; // suspension animation
car_player();
}

action plant()
{
set(my,SHADOW);
vec_scale(my.scale_x,0.4+random(0.4));
ent_terrain_place(my,level_ent,55,70);
my.z -= 10*my.scale_z;
my.pan = random(360);
my.tilt = random(30)-15;
pXent_settype(me,PH_RIGID,PH_CONVEX);
pXent_setsleep(my,1); // only wake up on collision
}

function main()
{
video_window(0,0,0,"PhysX Car Practice Level");
shadow_stencil = 3;
shadow_lod = 2;
d3d_antialias = 4; // Commercial Edition and above only
on_esc = quit;

physX_open();
level_loadsplash("terrain.hmp","logo_800.jpg",0);
terrain_fence(level_ent,150); // build a wall around the terrain
pXent_settype(level_ent,PH_STATIC,PH_POLY|PH_MODIFIED); // update the terrain collision shape
tcamera_height = 75;
sun_angle.tilt = 60;
ent_createlayer("skycube+6.dds",SKY|CUBE|SHOW,0);
ent_create("vehicle_1.mdl",terrain_pos(NULL,300,0,30),knight_on_wheels);
int i;
for (i=0; i < NUM_PLANTS; i++)
ent_create("cactus.mdl",NULL,plant);
}

.................................................................................................................................................................
what i want to ask, does anyone know how to change the code so that when the user press a key (ex. space bar) the car body will be moved from it is place to another place "specific".

Re: how to change car position? [Re: sbaya] #367936
04/20/11 07:57
04/20/11 07:57
Joined: Apr 2011
Posts: 40
germany
W
Wollez Offline
Newbie
Wollez  Offline
Newbie
W

Joined: Apr 2011
Posts: 40
germany
Hi sbaya,
The action of the car is knight_on_wheels. In the end theres a function call car_player(). write this function above the action and put your code there. It could look like:
Code:
function car_player()
{
  while(1)
  {
     if (key_space) c_move(me,vector(whatever),Null or sth); //check the manual for c_move
     wait(1);
  }
action knight_on_wheels()
...


i'm not exoerienced in gamestudio, so I'd be glad if some experts could correct my code a bit.

PS: please use code tags [code ] your code here [/code] (remove spaces)

Re: how to change car position? [Re: Wollez] #368169
04/22/11 11:27
04/22/11 11:27
Joined: Dec 2010
Posts: 9
S
sbaya Offline OP
Newbie
sbaya  Offline OP
Newbie
S

Joined: Dec 2010
Posts: 9
Thank you for replying ..
i tried your suggestion, but it did not work because there are phys applied to the car.
here, i read something in phys FAQ:
Quote:
Q: How do I move a physics entity ?
A: Apply a velocity, force or torque to it. If you have set up a constraint on the object, you can also use the phcon_setmotor function to set its movement. Don't attempt to change its position or orientation directly by altering his x,y,z coordinates or angles, or by c_move or c_rotate - this won't work for physics entities.

i tried using 'phcon_' but did not succeed..
hope that someone can help me.

Re: how to change car position? [Re: sbaya] #368170
04/22/11 11:29
04/22/11 11:29
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
I'm planing to contribute "fake physics" for car movement, let me know if you'll need that.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: how to change car position? [Re: 3run] #368199
04/22/11 15:36
04/22/11 15:36
Joined: Dec 2010
Posts: 9
S
sbaya Offline OP
Newbie
sbaya  Offline OP
Newbie
S

Joined: Dec 2010
Posts: 9
Hi,3run
what do you mean by "fake physics" for car movement?, if it can help me moving my car then i sure need it.
thank you...


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