Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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 | chip programmers | 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