0 registered members (),
17,416
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
how to change car position?
#367579
04/14/11 22:34
04/14/11 22:34
|
Joined: Dec 2010
Posts: 9
sbaya
OP
Newbie
|
OP
Newbie
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
Wollez
Newbie
|
Newbie
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:
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
sbaya
OP
Newbie
|
OP
Newbie
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: 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.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|