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
Posted By: txesmi
Re: Movement - 06/01/18 07:10
Hi,
pXent_move moves physx actors with no collision detection. On pX, actors are moved with forces. pXent_addforcelocal adds forces in object space.
Salud!
Posted By: Kartoffel
Re: Movement - 06/01/18 08:15
what txesmi said, unless you're using a kinematic character. In that case you have to use pXent_move().
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);
}
}
Posted By: Kartoffel
Re: Movement - 06/03/18 08:55
you have to register your entities as physics objects
Thanks. Umm. How do I do that please?
Posted By: Kartoffel
Re: Movement - 06/04/18 20:29
Take a look at the physics workshop at
http://tutorial.3dgamestudio.net/