1 registered members (TipmyPip),
18,449
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
What am I doing wrong?
#42213
03/07/05 09:13
03/07/05 09:13
|
Joined: Jan 2005
Posts: 22 New Zealand
SteveIRL
OP
Newbie
|
OP
Newbie
Joined: Jan 2005
Posts: 22
New Zealand
|
Hi guys, I just upgraded to the commercial edition 6.31.4 (and am trying to make physics work (I couldn't make it work in the trial; was it disabled?). I've got a script which I think should create an entity then send that entity off into the sunset. For some reason this isn't working. Here's the script, what have I done wrong? Code:
var video_mode = 8; // screen size 1024x768 var video_depth = 32; // 32 bit colour D3D mode
string lvlStr = <junk.wmb>; string witchStr = <cbabe.mdl>;
var witchPos[3] = 100, 0, 20; var witchForceVec[3] = 0, 0, 200;
entity* witch;
function physFunction() { witch = me; phent_settype(witch, ph_rigid, ph_box); ph_setgravity(nullvector); phent_setmass(witch, 10, PH_BOX); phent_setdamping (witch, 0, 0); while(1) { if(key_a == 1) { phent_addcentralforce(witch, witchForceVec); } wait(1); } phent_settype(witch, 0, 0); }
function main() { level_load(lvlStr); wait(1); ent_create(witchStr, witchPos, physFunction); }
Steve
I'm on a diet of black coffee and prozac buttered toast.
|
|
|
Re: What am I doing wrong?
[Re: Helghast]
#42216
03/09/05 06:38
03/09/05 06:38
|
Joined: Jan 2005
Posts: 22 New Zealand
SteveIRL
OP
Newbie
|
OP
Newbie
Joined: Jan 2005
Posts: 22
New Zealand
|
Did you know: the physics stuff only works inside a complete environment. I had built a simple test level consisting of a large cube. The testing took place on top of this cube. I tried again inside a cube and everything worked fine. I hate computers. I need more prozac buttered toast. Quote:
only actions can be attached
It's my understanding that an action is attached by the world editor and a function is attached by ent_create. To quote the manual:
Quote:
ent_create(string filename, vector Position, function);
and then:
Quote:
The given function will start immediately after creation
The word action is never mentioned. Is my understanding of the situation correct, or am I attaching the wrong things?
Thanks guys.
Steve
I'm on a diet of black coffee and prozac buttered toast.
|
|
|
Re: What am I doing wrong?
[Re: SteveIRL]
#42217
03/21/05 11:55
03/21/05 11:55
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
Serious User
|
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
I think its supposed to be "the given action", because you cant assign a function alone to an entity. You need to assign and action, which calls functions inside of it. Below is a snippet taken from Grimber's phyisics tutorial:
Action my_car { //added default camera player = my; //set me to the player //first we let the engine know what type the physics object is phent_settype(my,PH_RIGID,PH_box); //next we set the mass of the object phent_setmass(my,23,PH_box); //we then set the friction we want phent_setfriction(my,25); //then we set the elasticity of the object (bounciness) phent_setelasticity(my,50,5); //then we set the damping phent_setdamping(my,50,90); //then we set our world gravity ph_setgravity ( vector(0,0,-386) ); }
All of that is called within an action, and will be exececuted once the entity is created. Just change the function word to action:
function physFunction() { witch = me; phent_settype(witch, ph_rigid, ph_box); ph_setgravity(nullvector); phent_setmass(witch, 10, PH_BOX); phent_setdamping (witch, 0, 0); while(1) { if(key_a == 1) { phent_addcentralforce(witch, witchForceVec); } wait(1); } phent_settype(witch, 0, 0); }
action Marmaduke_Physics_Object
{ witch = me; phent_settype(witch, ph_rigid, ph_box); ph_setgravity(nullvector); phent_setmass(witch, 10, PH_BOX); phent_setdamping (witch, 0, 0);
while(1) { if(key_a == 1) { phent_addcentralforce(witch, witchForceVec); } wait(1); } phent_settype(witch, 0, 0);
}
|
|
|
Re: What am I doing wrong?
[Re: jumpman]
#42218
03/21/05 16:27
03/21/05 16:27
|
Joined: Jan 2003
Posts: 710
Templar
Developer
|
Developer
Joined: Jan 2003
Posts: 710
|
Quote:
It's my understanding that an action is attached by the world editor and a function is attached by ent_create. To quote the manual:
You're right. You can attach a function to an entity in WED - but you would have to type it in itself, it would show in the actions list. You can ass well assign an action to it via ent_create. The actions are basicaly functions that are shown in wed.
|
|
|
Re: What am I doing wrong?
[Re: SteveIRL]
#42219
03/26/05 11:34
03/26/05 11:34
|
Joined: Sep 2003
Posts: 3,236 San Diego, CA
Marco_Grubert
Expert
|
Expert
Joined: Sep 2003
Posts: 3,236
San Diego, CA
|
Quote:
Did you know: the physics stuff only works inside a complete environment. I had built a simple test level consisting of a large cube. The testing took place on top of this cube. I tried again inside a cube and everything worked fine.
The physics engine checks whether objects have leaked out of the level and stops them before that happens. If you place them outside the level they will just stay there.
|
|
|
|