Physics for level

Posted By: MPQ

Physics for level - 01/02/09 13:40

Hello,
At the moment I try to look through the Physic-Engine of 3DGS. If I include eg. gravity power I cant move my model any more.
Does anybody know a tutorial how to use the Engine?

Here my test-script (whats wrong? I cant move on key_i/key_l):
Quote:
function main()
{
level_load ("Physik.wmb");
wait(2);
ph_setgravity (vector (0, 0, -386));//9.81m/s^2
camera.x = - 50;
}

action model()
{
phent_settype (my, PH_RIGID, PH_BOX);
phent_setmass (my, 3, PH_BOX);
while(1)
{
if (key_i) my.x += 6 *time_step;
if (key_l) my.x += -6 *time_step;
wait(1);
}
}

Posted By: Quad

Re: Physics for level - 01/02/09 13:44

you have to move your object using phent_ functions if you use the physics engine on that object.
Posted By: MPQ

Re: Physics for level - 01/02/09 21:45

Ok now ive decided to use c_move, but the prob is that my model only move one step (1000*time_step) when I add the "settype" and then it stops in spite of the while-loop. Whats wrong?
Quote:
#include <acknex.h>
#include <default.c>
////////////////////////////
var speed1;

function main()
{
level_load ("Physik.wmb");
wait(2);
ph_setgravity (vector (0, 0, -386));
camera.x = 50;

}

action model()
{
phent_settype (my, PH_RIGID, PH_BOX);

while(1)
{

if (key_i) speed1 = 10 * time_step;
c_move (my, nullvector, vector(0, speed1, 0), NULL);
wait(1);
}

}

Posted By: Spirit

Re: Physics for level - 01/02/09 22:08

Why do you ask here when you dont read the responses? You have to move your object with phent_ functions, not c_move.

And why dont you read the physics tutorial before you start to script? You have to understand the basics before you can program something. I think spending 10 minutes to read the tutorial page is faster than randomly trying commands and then wondering why it does not work.
Posted By: MPQ

Re: Physics for level - 01/02/09 22:34

sorry, I thought c_move would work with the physic-engine?! I have tried the phent_function but I didnīt get how those work
Quote:
And why dont you read the physics tutorial before you start to script?

oh yes. I have done it but the information you get from it is really a bit too little. Do you know some tut?
Posted By: Spirit

Re: Physics for level - 01/02/09 22:41

No, but the lessons about physics and movement are ok for programming simple movement. For more complicated movement, just ask here.

When physics has control over an entity, you can not move it manually. When you want to move it yourself, don't make it a physics object.
Posted By: pewpew

Re: Physics for level - 01/04/09 00:47

duuuude im having the EXACT same problem!!! nobody told me that you cant use 'c_move' when you apply physics to something lol. ive been trying to drive a tank around a map for 2 months.

ok, so you CANT use c_move?

when i go into the physics section in the help menu, you click on "phent_" and it says-
"Here is a list of phent_ commands..."
and thats it. a blank page lol.
Posted By: MPQ

Re: Physics for level - 01/04/09 11:05

ok you cant use c_move wink At the moment I try with phent_fuction like phent_centralforce and it works so far.

The following is my test script for a movement with physics:
Quote:
#include <acknex.h>
#include <default.c>
////////////////////////////
VECTOR speed1;

function main()
{
level_load ("Physik.wmb");
wait(2);
ph_setgravity (vector (0, 0, -386));
camera.x = 50;

}

action model()
{

phent_settype (my, PH_RIGID, PH_BOX);
phent_setdamping (my, 80, 80);
while(1)
{

//speed up!//
if (key_i && (speed1.x < 50 && (speed1.x >= 0)))//speed up forwards, if speed1 is 0 or higher
speed1.x += 0.02;
if (key_k && (speed1.x > -10 && (speed1.x <= 0)))//speed up backward, if speed1 is lower than 0
speed1.x -= 0.02;

//break!//
if (key_i && (speed1.x < 0))//break, if speed1 is lower 0
speed1.x += 0.04;
if (key_k && (speed1.x > 0))//break, if speed1 is higher than 0
speed1.x -= 0.04;
if (!key_i && !key_k) speed1.x = 0;

phent_addcentralforce (my, speed1);
//phcon_setmotor//ph_setautodisable//ph_autodisable//ii
wait(1);
}

}

Posted By: Jazuar_

Re: Physics for level - 01/04/09 12:02

@ pewpew

that's just the introductory page for the rest of the phent_whatever pages
look for things like phent_addcentralforce and the like
© 2024 lite-C Forums