Throw Objects
From GameStudio Wiki
The following script creates a physicsobject at the cameras position and adds a force into view direction to it. Call it from within the function main like this:
Phy_debug_throw("stein1.mdl",200000);
Where the first parameter is the file name of the model to be created and the second the force to throw it with.
void Phy_debug_throw(char* Filename,strength)
{
var temp[3];
while(1)
{
if(mouse_left)
{
you = ent_create(Filename,camera.x,NULL);
vec_set(you.pan,camera.pan);
//Play around with these Values if needed
phent_settype(you,PH_RIGID,PH_BOX);
phent_setmass(you,5,PH_BOX);
phent_setelasticity(you,10,5);
phent_setfriction(you,30);
phent_setdamping(you,5,3);
temp[0] = 1;
temp[1] = 0;
temp[2] = 0;
vec_rotate(temp[0],camera.pan);
vec_scale(temp[0],strength);
phent_addcentralforce(you,temp[0]);
wait(-0.2);
}
wait(1);
}
}
--Slin 01:48, 4 November 2007 (CET)
