EVENT_ENTITY with PhysX

Posted By: CanadianDavid

EVENT_ENTITY with PhysX - 06/25/14 21:34

I notice that when I use the PhysX engine to move an object, the EVENT_ENTITY never triggers despite saying in the documentation that it also responds to "physics entity movement".

Consider the following code (download demo):
Code:
#include <acknex.h>
#include <ackphysx.h>

function ball_event(){
	beep();
}

action ball(){
	my.emask |= ENABLE_ENTITY;
	my.event = ball_event;
	pXent_settype (me, PH_RIGID, PH_SPHERE); // set the physics entity type
	pXent_setfriction (me,50); // set the friction on the ground
	pXent_setdamping (me,10,10); // set the damping
	pXent_setelasticity (me,50); // set the elasticity
	
	while(1){
		//c_move(me,nullvector,vector(time_step,0,0),GLIDE);
		pXent_addforcecentral(me,vector(time_step,0,0));
		wait(1);
	}
}

action hero(){
	player = me;
	while(1){
		vec_set(camera.x, my.x);
		camera.pan = my.pan;
		c_move(me,vector(key_w-key_s,key_a-key_d,0),nullvector,GLIDE);
		wait(1);
	}
}

void main() {
	physX_open();
	level_load("level1.wmb");
}

When the ball collides with the player using c_move, the event is triggered and a beep is heard. When PhysX is used, the event is not triggered. How can I trigger an EVENT_ENTITY using PhysX?
Posted By: txesmi

Re: EVENT_ENTITY with PhysX - 06/25/14 21:53

Hi,
take a look to pXent_setcollisionflag.

Salud!
Posted By: CanadianDavid

Re: EVENT_ENTITY with PhysX - 06/26/14 09:18

To react with the player, would I need to either register the player model as a PhysX enabled object or attach a dummy PhysX object to it for it to work? How might I attach a dummy PhysX object to the player model since I cannot modify the xyz values directly unless I first unregister the dummy object?

My current player model is not a registered PhysX object; the player is moved using c_move instructions.
© 2024 lite-C Forums