Player not moving on action.

Posted By: Xyro

Player not moving on action. - 09/29/11 09:57

So I am writing some code where a player gets hurt by a spike, so I made a spike action which I give to a spike. It detects the collision between the player and the spike but I can't seem to get my mainCharacter to move back to its old position.

Code from my actions.c :

ENTITY* mainCharacter;
float startPos[3];

action characterStartup()
{
mainCharacter = me;
startPos[0] = mainCharacter.x;
startPos[1] = mainCharacter.y;
startPos[2] = mainCharacter.z;
pXent_settype (mainCharacter, PH_RIGID, PH_SPHERE);
pXent_setfriction (mainCharacter,60);
pXent_setmass(mainCharacter,1);
pXent_setdamping (mainCharacter, 30,30);
pXent_setelasticity (mainCharacter,50);
pXent_setccdskeleton(mainCharacter, nullvector, 1);
c_setminmax(mainCharacter);
}

function PlayerDeath()
{
mainCharacter.x = startPos[0];
mainCharacter.y = startPos[1];
mainCharacter.z = startPos[2];
}

action SpikeHurt()
{
while(!mainCharacter) wait(1);
pXent_settype (me, PH_STATIC, PH_SPHERE);
pXent_setcollisionflag(me, mainCharacter, NX_NOTIFY_ON_START_TOUCH);
me.event = PlayerDeath;
}

The mainCharacter has the characterStartup action assigned to it.

So what did I do wrong ?
Posted By: swerning

Re: Player not moving on action. - 09/29/11 11:22

You can't change the position of a PhysX entity directly by setting its x,y,z value. Use pxEnt_setposition (http://www.conitec.net/beta/pXent_setposition.htm) in your PlayerDeath function instead to reposition the player.
Posted By: Xyro

Re: Player not moving on action. - 09/30/11 19:40

Thanks, worked perfectly
© 2024 lite-C Forums