2 registered members (AndrewAMD, VoroneTZ),
779
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Movement
#472942
06/01/18 02:12
06/01/18 02:12
|
Joined: May 2018
Posts: 7
LaserJock2000
OP
Newbie
|
OP
Newbie
Joined: May 2018
Posts: 7
|
I have a car entity on an arena. The car drives well with my joystick however I want to drive it in a relative vice absoulute fashion. AKA: I want the car to drive forward based on entity not world coordinates. I have tried both: pXent_move(me, vector(my.x -= joy_axis(1,2) * .01, my.y -= joy_axis(1, 1) * .01, my.pan -= joy_axis(1, 4) * .01), nullvector); and
c_move(me, vector(my.x -= joy_axis(1,2) * .01, my.y -= joy_axis(1, 1) * .01, my.pan -= joy_axis(1, 4) * .01), nullvector, GLIDE);
The car always drives in world coordinates.
Any ideas? Thanks
|
|
|
Re: Movement
[Re: txesmi]
#472947
06/01/18 08:15
06/01/18 08:15
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
what txesmi said, unless you're using a kinematic character. In that case you have to use pXent_move().
POTATO-MAN saves the day! - Random
|
|
|
Re: Movement
[Re: Kartoffel]
#472963
06/03/18 01:35
06/03/18 01:35
|
Joined: May 2018
Posts: 7
LaserJock2000
OP
Newbie
|
OP
Newbie
Joined: May 2018
Posts: 7
|
Good point. Here is my code. The car drives but goes through the arena walls and is always in world coordinates.
//////////////////////////////////////////////////////////////////// #include <default.c> #include <ackphysx.h> ////////////////////////////////////////////////////////////////////
// joyNum 1/2, axisNum 1-6 var joy_axis(int joyNum, int axisNum) { VECTOR *source[2]; if(axisNum < 1 || axisNum > 6) return 0; if(joyNum == 2) { source[0] = &joy2_raw; source[1] = &joy2_rot; } else { source[0] = &joy_raw; source[1] = &joy_rot; } axisNum--; var *pv = source[axisNum/3]; return pv[axisNum%3]; // read var at x,y,z }
function main() { VECTOR Car1; ENTITY* Car1; ENTITY* Level1; physX_open(); video_mode = 12; level_load ("2018_arena_MKIII.wmb"); Car1 = ent_create (Car1, vector(64, 100, 2.5), NULL); // create the Car Level1 = ent_create ("2018_arena_MKIII.wmb", vector(0,0,0), NULL);
wait (2);
} action move_me() { while (1) { pXent_move(me, vector(my.x -= joy_axis(1,2) * .01, my.y -= joy_axis(1, 1) * .01, my.pan -= joy_axis(1, 4) * .01), nullvector); wait (1); } }
|
|
|
|