|
Re: Pushing.
[Re: dirt]
#316985
03/28/10 13:30
03/28/10 13:30
|
Joined: Mar 2009
Posts: 11 -
tehVolcano
Newbie
|
Newbie
Joined: Mar 2009
Posts: 11
-
|
You should use the physics engine to do that for you. Instead of using c_move, try this:
action spaceship()
{
phent_settype(me,PH_RIGID,PH_BOX);
phent_setmass(me,1000);
phent_setdamping(me,0,0);
phent_enable(me,1);
//All your spaceship code.
}
You should use the physics engine to do that for you. Instead of using c_move, try this:
action spaceship()
{
phent_settype(me,PH_RIGID,PH_BOX); //Turn the ship into a physics entity
phent_setmass(me,1000); //Set the mass, bigger ships should have a higher mass.
phent_setdamping(me,100,100); //Set the damping, angular and linear...
phent_enable(me,1); //Turn on physics engine for this ship.
//All your spaceship code.
}
Then, for setting the rotation of the spaceships, simply do this:
//code before setting rotation
phent_enable(me,0); //Allow manual position and rotation changes
wait(1); //Wait one frame to make sure the changes are actually made
//Set pan, tilt, roll
wait(1); //Wait one frame to prevent glitches
phent_enable(me,1); //Enable physics for the ship
//Code after rotating
To move the spaceships, use the phent_addvellocal function.
phent_addvellocal(me,vector(0,-20,0),vector(0,0,0));
Be sure not to change the second vector, else your spaceship will fly a curve. The second vector is like the thruster position, and the thruster should be in the center of the ship for optimal flight behaviour. Also, if the ship flies sideways, try
phent_addvellocal(me,vector(-20,0,0),vector(0,0,0));
Also, I guess you don't want any gravity. Put this into function main:
ph_setgravity(vector(0,0,0)); //Zero gravity
Gamestudio A7 Pro
|
|
|
Re: Pushing.
[Re: tehVolcano]
#316986
03/28/10 13:35
03/28/10 13:35
|
Joined: Mar 2009
Posts: 11 -
tehVolcano
Newbie
|
Newbie
Joined: Mar 2009
Posts: 11
-
|
I forgot to mention that phent_setdamping(me,100,100); causes the ship to stop moving or rotating unless a force acts on it. If you use values lower than 100, the ships will take some time to slow down, and if you use 0, then the entity will keep going on forever until it collides with something else, or you apply a force to it.
Gamestudio A7 Pro
|
|
|
|