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
1 registered members (TipmyPip), 18,449 guests, and 6 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
What am I doing wrong? #42213
03/07/05 09:13
03/07/05 09:13
Joined: Jan 2005
Posts: 22
New Zealand
S
SteveIRL Offline OP
Newbie
SteveIRL  Offline OP
Newbie
S

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: SteveIRL] #42214
03/08/05 05:49
03/08/05 05:49
Joined: Sep 2003
Posts: 3,236
San Diego, CA
M
Marco_Grubert Offline
Expert
Marco_Grubert  Offline
Expert
M

Joined: Sep 2003
Posts: 3,236
San Diego, CA
Code looks good. Try putting breakpoints in there to make sure that all the statements are indeed executed.

Re: What am I doing wrong? [Re: Marco_Grubert] #42215
03/08/05 14:57
03/08/05 14:57
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
maybe a stupid question, but you sure you assigned that to the model *i see it's a function, only actions can be attached :P*

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
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
S
SteveIRL Offline OP
Newbie
SteveIRL  Offline OP
Newbie
S

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 Offline
Serious User
jumpman  Offline
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
T
Templar Offline
Developer
Templar  Offline
Developer
T

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
M
Marco_Grubert Offline
Expert
Marco_Grubert  Offline
Expert
M

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.


Moderated by  HeelX, Spirit 

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