Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 17,340 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Player not moving on action. #384098
09/29/11 09:57
09/29/11 09:57
Joined: Sep 2011
Posts: 11
X
Xyro Offline OP
Newbie
Xyro  Offline OP
Newbie
X

Joined: Sep 2011
Posts: 11
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 ?

Re: Player not moving on action. [Re: Xyro] #384104
09/29/11 11:22
09/29/11 11:22
Joined: Aug 2005
Posts: 14
Bayreuth, Germany
S
swerning Offline
Newbie
swerning  Offline
Newbie
S

Joined: Aug 2005
Posts: 14
Bayreuth, Germany
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.

Re: Player not moving on action. [Re: swerning] #384211
09/30/11 19:40
09/30/11 19:40
Joined: Sep 2011
Posts: 11
X
Xyro Offline OP
Newbie
Xyro  Offline OP
Newbie
X

Joined: Sep 2011
Posts: 11
Thanks, worked perfectly


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1