catapult physics

Posted By: Falke3D

catapult physics - 09/05/04 01:33

Hello,

i want a catapult, to throuw a stone away.
My physic-stone is rolling away, becouse the catapult.mdl don't hold
the stone.
I want a realistic physicel-effekt.
can you help me ?

-- Thanx --
Posted By: fastlane69

Re: catapult physics - 09/05/04 04:04

Dont't model the catapult as one MDL. Rather, use a series of MDLs put together to model the catapult.

For example, use Three Models to build your basket. Now, put these models (which could be as simple as just rectangles) on the end of you catapult arm and rest your Projectile within this basket. Now it shouldn't roll away and as you move your Catapult arm, it should carry the projectile with it and simulate a Catapult.

Since you don't have the option of concave geometry till octree comes online, this is the only way (I think) that you'll get the basket effect neccessary for a catapult.
Posted By: Nardulus

Re: catapult physics - 09/05/04 04:34

Get a vertex id basically a point in the basket part of your Catapult model.

You can then get an xyz coordinate in world space. You can manually attach your rock to that vertex position. Use the "vec_for_vertex" command.

Once you have an animation of your catapult throwing the rock, have your rock track the basket vertex, update the rocks position until you reach a predefined frame in your animation where you want to throw the rock as a projecticle. At this point you can enable physics on the rock and let the physics system take over. You will have to give the rock, force variables, and how it is going to react with gravity.


Ken
Posted By: Falke3D

Re: catapult physics - 09/05/04 08:15

OK, i send my codes for the catapult, but its not my Code.
This code is from a other user in the Forum, i only modifies the Code.
The long Code:


define aniseq, skill30; // Aniseq für Animation ist skill 30
var Soundhandle;
var Musiklautstaerke = 75;
/* Lautstärke der Geräusch */
var Soundlautstaerke = 80;

sound CATA_WURF = <catawurf.wav>;
sound Cat_SPANN = <catspann.wav>;


var shoot;
var absspeed[3];
var t,1;
bmap panel=<PANEL.pcx>;
var timex,1;
var _angle,40;

ACTION fireball_cat
{
timex=1;absspeed.x=0;abspeed.y=0;
vec_scale(MY.SCALE_X,actor_scale); // use actor_scale
MY.ENABLE_BLOCK = ON;
MY.ENABLE_ENTITY = ON;
MY.ENABLE_STUCK = ON;
MY.ENABLE_IMPACT = ON;
MY.ENABLE_PUSH = ON;
MY.EVENT = _fireball_event;
// *********** added for fireball:
my.flare = ON;
my.bright = ON;
my.oriented = off;
my.alpha = 100;
my.scale_x = 0.6;
my.scale_y = 0.6;
my.scale_z = 0.6;
// ***********
// *********** light values changed
MY.LIGHTRED = 100;
MY.LIGHTGREEN = 50;
MY.LIGHTBLUE = 20;
// ***********
MY.LIGHTRANGE = 100;
MY.AMBIENT = 100;
MY.SKILL2 += 2;
MY.SKILL3 += 2;
MY.SKILL4 += 2;
MY._DAMAGE = damage;
MY._FIREMODE = fire_mode;
// my.near is set by the explosion
while(your._animdist<60)
{
wait(1); // wait at the loop beginning, to let it appear at the start position
vec_for_vertex(temp,your,392);
// *********** added fire trail
// *********** added fire trail
my_fireball2();

//temp = TIME;
//if(temp > 1.5) { temp = 1.5; } // make bullet slower on slow PCs
// *********** slow speed down
//temp = temp / 8;
// MOVE moves by a distance, so multiply the speed by time.

my.x=temp.x;
my.y=temp.y;
my.z=temp.z;
my.pan=your.pan;
vec_scale(fireball_speed,movement_scale); // scale fireball_speed by movement_scale

}
while((MY.NEAR != ON))
{
wait(1); // wait at the loop beginning, to let it appear at the start position
// *********** added fire trail
my_fireball2();


// MOVE moves by a distance, so multiply the speed by time.
absspeed.x=0;
absspeed.y=-((0.825*my.skill20*cos(_angle))*time);
absspeed.z=(((0.825*sin(_angle)*my.skill20)-(.009*my.skill20*my.skill20))*time);
vec_scale(fireball_speed,movement_scale); // scale fireball_speed by movement_scale
move(ME,absspeed,nullvector);
my.skill20+=.85 ;
}
my.skill20=1;
}
// ****************** fireball function without loop and scaling *****************
function my_fireball2(){
if(player == NULL) { return; }
my.skill10 = my.x + random(2) - 1;
my.skill11 = my.y + random(2) - 1;
my.skill12 = my.z + random(2) - 1;
my.skill13 -= 1;
if (my.skill13 <= 0) {
my.skill13 = 2 / TIME;
emit(1,my.skill10,fireball_particle2);
my.skill10 = my.x + random(2) - 1;
my.skill11 = my.y + random(2) - 1;
my.skill12 = my.z + random(2) - 1;
emit(1,my.skill10,fireball2_particle2);
}
}
function fireball_particle2(){
if(my_age == 0) {
my_alpha = 0;
my_speed.x = random(1.5) - 0.75;
my_speed.y = random(1.5) - 0.75;
my_speed.z = random(1.5) - 0.75;
my_size = 500+random(1200);
my_map = fireball_map;
//my_transparent = on;
my_flare = on;
my_bright= on;

return;
}
if((player == NULL) | | (MY_AGE > 12)) {
MY_ACTION = NULL;
}
if (my_age > 1) {
my_alpha = 100-MY_AGE*8;
} else { my_alpha = my_age * 40; }
}
function fireball2_particle2(){
if(my_age == 0) {
my_alpha = 0;
my_speed.x = random(1) - 0.5;
my_speed.y = random(1) - 0.5;
my_speed.z = random(1) - 0.5;
my_size = 1100+random(400);
my_map = fireball2_map;
//my_transparent = on;
my_flare = on;
my_bright= on;
return;
}
if((player == NULL) | | (MY_AGE > 10)) {
MY_ACTION = NULL;
}
if (my_age > 0) {
my_alpha = 100-MY_AGE*9;
} else { my_alpha = 50; }
}






}


ACTION fireball_cat_ph
{
timex=1;absspeed.x=0;abspeed.y=0;
vec_scale(MY.SCALE_X,actor_scale); // use actor_scale
MY.ENABLE_BLOCK = ON;
MY.ENABLE_ENTITY = ON;
MY.ENABLE_STUCK = ON;
MY.ENABLE_IMPACT = ON;
MY.ENABLE_PUSH = ON;
MY.EVENT = _fireball_event;
// *********** added for fireball:
my.flare = ON;
my.bright = ON;
my.oriented = off;
my.alpha = 100;
my.scale_x = 0.6;
my.scale_y = 0.6;
my.scale_z = 0.6;
// ***********
// *********** light values changed
MY.LIGHTRED = 100;
MY.LIGHTGREEN = 50;
MY.LIGHTBLUE = 20;
// ***********
MY.LIGHTRANGE = 100;
MY.AMBIENT = 100;
MY.SKILL2 += 2;
MY.SKILL3 += 2;
MY.SKILL4 += 2;
MY._DAMAGE = damage;
MY._FIREMODE = fire_mode;
// my.near is set by the explosion
while(your._animdist<60)
{
wait(1); // wait at the loop beginning, to let it appear at the start position
vec_for_vertex(temp,your,345);

// *********** added fire trail
// Geschoss();


//temp = TIME;
//if(temp > 1.5) { temp = 1.5; } // make bullet slower on slow PCs
// *********** slow speed down
//temp = temp / 8;
// MOVE moves by a distance, so multiply the speed by time.

my.x=temp.x;
my.y=temp.y;
my.z=temp.z;
my.pan=your.pan;
vec_scale(fireball_speed,movement_scale); // scale fireball_speed by movement_scale

}
while((MY.NEAR != ON))
{



// MOVE moves by a distance, so multiply the speed by time.
absspeed.x=0;
absspeed.y=-((0.925*my.skill20*cos(_angle))*time);
absspeed.z=(((0.925*sin(_angle)*my.skill20)-(.009*my.skill20*my.skill20))*time);
vec_scale(fireball_speed,movement_scale); // scale fireball_speed by movement_scale
move(ME,absspeed,nullvector);
my.skill20+=.65 ;
}
my.skill20=1;

}



action Geschoss
{
Gestein();
my.shadow=on;

phent_settype(my,PH_RIGID,PH_SPHERE);
phent_setmass(my,15,PH_SPHERE);
phent_setfriction(my,30);
phent_setelasticity(my,50,20);
phent_setdamping(my,20,20);

}


action Stein_kugel
{
Gestein();
my.shadow=on;

phent_settype(my,PH_RIGID,PH_SPHERE);
phent_setmass(my,10,PH_SPHERE);
phent_setfriction(my,70);
phent_setelasticity(my,25,20);
phent_setdamping(my,30,10);
}


function anim_WURF_ph()
{
while(1)
{
ent_cycle("base",my._animdist);

if (shoot==1)
{
my._animdist=0;

create(<Stein_Kugel.mdl>,temp,Geschoss);
while(my._animdist<200)
{
my._animdist+=time*30;
ent_cycle("throw",my._animdist);
play_entsound(my,CATA_WURF,Soundlautstaerke);
// fireball_cat_ph();
wait(1);
}
shoot=2;
gun_shot();
wait(30);
ent_cycle("base",my._animdist);
play_entsound(my,CAT_SPANN,Soundlautstaerke);
}
wait(1);
}
//vec_for_vertex(temp,my,345);
}


}


//function anim_WURF()
//{
//while(1)
//{
//if (shoot==1)
//{
// my._animdist=0;
// vec_for_vertex(temp,my,392);
// create(<Stein_Kugel.tga>,temp,fireball_cat);
// while(my._animdist<100)
// {
// my._animdist+=time*8;
// ent_cycle("throw",my._animdist);
// play_entsound(my,CATA_WURF,Soundlautstaerke);
// wait(1);
// }
// shoot=2;
// gun_shot();
// ent_cycle("base",my._animdist);
// play_entsound(my,CAT_SPANN,Soundlautstaerke);
//}
//wait(1);
//}
//}






function c_event()
{
if(event_type==event_click)
{
shoot=1;
}
}

function anim_SPANN()
{
ent_cycle("move",my.aniseq -0.02);
play_entsound(my,CAT_SPANN,Soundlautstaerke);
wait(1);
}


//action catapult
//{
//Shader_bumpmap();
//my.trigger_range = 12;
//my.enable_click=on;
//my.event=c_event;
//anim_WURF();
//wait(10);
//anim_SPANN();
//wait(10);
//
//}
//

on_s = anim_SPANN();



action catapult_Ph
{
Shader();

my.trigger_range = 12;
my.enable_click=on;
my.event=c_event;
anim_WURF_ph();
wait(10);
anim_SPANN();
wait(10);

}


------------------------

The fireball should be replaced with the physics

You think i should have 3 MDL to realizes that action with a basket ?

--- Thank you for your opinion ---
© 2024 lite-C Forums