1 registered members (henrybane),
1,246
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Am I missing anything important?
#30385
07/14/04 01:42
07/14/04 01:42
|
Joined: May 2004
Posts: 46 Hanover, Germany
JRAV
OP
Newbie
|
OP
Newbie
Joined: May 2004
Posts: 46
Hanover, Germany
|
Am I missing anything important? Hi, I am successlessly trying to get the physics engine to work. I have A6 Pro 6.22. I have tried to follow the sample from AUM25, which works fine. Now I am trying to add a cube to one of my existing levels that is supposed to act like the sphere in the sample. I create the object, add the physic action -> and nothing happens You'd at least exspect the darn object to fall down to the the floor, wouldn't you? Here is the action I use: [..] entity* simpleCube; // A simple cube for testing ACTION PhysikCube { phent_settype(my, ph_rigid, ph_sphere); // enable physics for this ball phent_setmass(my, 1, ph_sphere); // the ball has 1kg (2 lbs) and behaves like a sphere phent_setfriction(my, 30); // friction phent_setelasticity(my, 30, 0); // bounce a little temp.x = 0; temp.y = 0; temp.z = -380; // earth gravity factor, g = 9.81 m/s2 ph_SetGravity(temp); // set gravity while (my.z > -150) {wait (1);} // the ball has approached the floor sleep (3); // give it 3 more seconds phent_setelasticity(my, 0, 0); // stop bouncing sleep (3); // give it 3 more seconds phent_settype(my, 0, ph_sphere); // now stop the ball } [..] function LoadTestCube() // Is called from the main to create the cube. { simpleCube = ent_create("simplecube.mdl",simpleCube_pos, PhysikCube); return; } [..] Am I missing anything important? Always my best, John
|
|
|
Re: Am I missing anything important?
[Re: JRAV]
#30388
07/14/04 06:25
07/14/04 06:25
|
Joined: Mar 2003
Posts: 5,377 USofA
fastlane69
Senior Expert
|
Senior Expert
Joined: Mar 2003
Posts: 5,377
USofA
|
Quote:
while (my.z > -150) {wait (1);} // the ball has approached the floor
Here is what I think is happening. I'm afraid it has nothing to do with the enabling commands as Nard suggested. This grouping feature is entirely optional and not necessary for using the PE:
a) You have a mass of 1. Don't try to model your world on a 1kg = 1 on the physics engine. 1 is a very low number which means that even the smallest of forces will upset it. On top of this, I suspect you are using a small model for the cube (less than 10 quants), thus few contact points.
Advice: Increase Mass and Model size. Don't use real world numbers as a guide, but rather how it looks and feels to you. Use Game REquirements, not actual Physics numbers to guide your selection.
b) Here's where I think the problem is:
Quote:
ACTION PhysikCube {
phent_settype(my, ph_rigid, ph_sphere); // enable physics for this ball phent_setmass(my, 1, ph_sphere); // the ball has 1kg (2 lbs) and behaves like a sphere phent_setfriction(my, 30); // friction phent_setelasticity(my, 30, 0); // bounce a little temp.x = 0; temp.y = 0; temp.z = -380; // earth gravity factor, g = 9.81 m/s2 ph_SetGravity(temp); // set gravity while (my.z > -150) {wait (1);} // the ball has approached the floor sleep (3); // give it 3 more seconds phent_setelasticity(my, 0, 0); // stop bouncing sleep (3); // give it 3 more seconds phent_settype(my, 0, ph_sphere); // now stop the ball
}
I have this gut feeling this line is the problem. It may be that you are starting at z= -200 for example, thus leaving you stuck in that loop. It may be that you are starting at LESS than -150, thus forcing you to blow though that line without even checking the loop. Or it could be something else, but that line distrubs me.
Advice: 1) You can use the minimumSpeed feature of phent_setelasticity to do what I think you want to do, which is stop the ball after a few bounces.
2)Eliminate the line in red and actually set up functions to control your ball in your action. It will make it easier to see what you want to do and figure out WHERE the problem is. For example:
Action ball { ball_init();//initiallize everything, from gravity to elasticity here. wait(1); //I like to take a small break after every initialization...just to be sure. while (1) { if( (my.z <50)&&(my.z>-50) ) //is we are less than 50 quants off the gound, but above -50 { stop_ball(); //Here is where you would reset the PE parameters to efffect the kind of stopping you want
} wait (1); }
Don't know if this is a specific solution, but check it out!
|
|
|
Re: Am I missing anything important?
[Re: Marco_Grubert]
#30390
07/14/04 17:59
07/14/04 17:59
|
Joined: May 2004
Posts: 46 Hanover, Germany
JRAV
OP
Newbie
|
OP
Newbie
Joined: May 2004
Posts: 46
Hanover, Germany
|
Hi folks, I think I got it: I have created a new project, added a hollow block, placed camera and cube inside and added physics -> works fine. Since I prefer an open environment, I created a sky cube and removed the walls and roof of the hollow block -> does not work anymore. Added the roof again -> worked fine. Looks like the physic objects have to be inside a hollow block. Is this a bug or a feature? Always my best, John
|
|
|
Re: Am I missing anything important?
[Re: JRAV]
#30391
07/15/04 03:35
07/15/04 03:35
|
Joined: Mar 2003
Posts: 5,377 USofA
fastlane69
Senior Expert
|
Senior Expert
Joined: Mar 2003
Posts: 5,377
USofA
|
FORGET THE PE AND LEARN THE REST OF 3DGS FIRST!!!!! If you dont' know that you have to use a skycube in every level for any game, even for a board game, then you have no buisness tackling the PE. This is not a bug; this is one of THE most basic requirements to making a game in 3DGS. Advice: a) Read the ENTIRE Manual....three times at least. b) Do the WeekLong introduction that is part of the manual. Had you done this, on day one you would have found this requirement and you would have never had this problem, even with your origianl code. c) As you are doing now, add the PE lastly. ONce you have your level and models in place, then and only then try to engage the PE. Just so you know, you've hit on two real pet peeves of mine: 1) Having alot of people put alot of time and thought into your problem, looking over your code, testing your code, etc only to find out it was a TRIVIAL error on your part that should never happen if you had read the included 3DGS literature. 2) Confusing your own ignorance of the engine for a BUG in the engine....this one really irks me when I spot it. JRAV, no harm, no foul and I wish you the best of luck. We are still and always here to help you but the nature of this thread tells me you ARE NOT ready for the PE and should take a few steps back and learn the rest of 3DGS first.
|
|
|
Re: Am I missing anything important?
[Re: fastlane69]
#30392
07/16/04 01:31
07/16/04 01:31
|
Joined: May 2004
Posts: 46 Hanover, Germany
JRAV
OP
Newbie
|
OP
Newbie
Joined: May 2004
Posts: 46
Hanover, Germany
|
Dear fastlane69, I have started to learn 3DGS about two months ago and covered all important aspects neccessary for the game I plan to create. I have tried physics several times, with no success, got back to different areas, and after trying for another two days or so I decided to finally ask for help in the forum. I knew that something trivial has been missing (otherwise my question would have been "what is wrong with the code", which worked perfectly well, and not "am i missing anything important", which I did). Marcos remark has helped me a lot (thanks for that, Marc ) and finally got me going. The lesson learned is that physics does not work in my skycube entity, which is ok, since I can work around that. Btw, this is not mentioned in the manual either, would be a great addition to the FAQ section since there may be other people as stupid as me. Now I am happily messing with PE trying to make it do what I want it to do and match it with the rest of my code Always my best, John
|
|
|
Re: Am I missing anything important?
[Re: JRAV]
#30393
07/16/04 03:35
07/16/04 03:35
|
Joined: Mar 2003
Posts: 5,377 USofA
fastlane69
Senior Expert
|
Senior Expert
Joined: Mar 2003
Posts: 5,377
USofA
|
Quote:
Since I prefer an open environment, I created a sky cube and removed the walls and roof of the hollow block -> does not work anymore.
Quote:
The lesson learned is that physics does not work in my skycube entity, which is ok, since I can work around that. Btw, this is not mentioned in the manual either, would be a great addition to the FAQ section since there may be other people as stupid as me.
Try this: Do the same thing, but comment out any and all physics. You will see (or rather not see) that as you look up, your screen refresh will muck about and give you weird black patches and echos of the screen. This is because there is nothing "beyond" the skycube.
Just to be clear as to how this is already in the manual, the second you REMOVE the walls and roof of your skycube, it CEASES to be a skycube. And the second that you lose the skycube, all 3DGS hell breaks loose, not just the PE, but the Graphics Engine (GE) and Scripting Engine (SE) as well. This is a basic lesson that I think the manual does a good job at explaining already, yes/no?
So there is nothing wrong with physics and your skycube or any skycube for that matter. The second you cease to have a skycube, then Physics is but the first of the infinite problems you will have.
BUT, now that you have a skycube, you will find working with the PE will be equal parts fustration and joy! And don't forget to read this forum index at least five times. There is ALOT of good hard earned knowledge about using the PE inside, just ready to answer questions you have or didn't know you had!!!!
GL
|
|
|
Re: Am I missing anything important?
[Re: fastlane69]
#30394
07/16/04 05:13
07/16/04 05:13
|
Joined: May 2004
Posts: 46 Hanover, Germany
JRAV
OP
Newbie
|
OP
Newbie
Joined: May 2004
Posts: 46
Hanover, Germany
|
Well, the screen refreshed fine. My mistake was that I created the skycube using the modeler and sky added skins inside the cube, so it was basically a solid cube PE is much more fun when object actually fall down to the floor than being stuck in what I suppoed to be air *LOL I admit that physics is not that easy, but at least I am getting forward Thanks and all the best, John
|
|
|
|