Posted By: MisterEd
Collision and model damage. - 08/17/10 00:45
Im trying to figure out some new stuff. Collisions and subsequent damage to the model(s).
In my test i have two capital ships and i run them into eachother.
I've set up some basic manouvering and shooting and when a collision takes place, my capship just 'halts' and nothing further happens (as intended atm).
My problem is, is that i have no idea what the next step should be to create damage to the models.
Do i need to make a model which consists of a group of models that are 'constructed' in game?
Or do i need to make 1 model and use animations to remove damaged parts of the ship?
Can i have parts breaking off and have it moving through space? I would love to see bits 'n pieces breaking off a capitalship when its in battle.
Can this all be done with the free version om gamestudio?
If anyone could give me some hints in how to approach the damage model and send me in the right direction, i'll try to put the pieces together
My code so far ( which is not all that much ):
Any comments or suggestions on my code are always welcome as i have no experience in this gamestuff whatsoever.
Ed.
In my test i have two capital ships and i run them into eachother.
I've set up some basic manouvering and shooting and when a collision takes place, my capship just 'halts' and nothing further happens (as intended atm).
My problem is, is that i have no idea what the next step should be to create damage to the models.
Do i need to make a model which consists of a group of models that are 'constructed' in game?
Or do i need to make 1 model and use animations to remove damaged parts of the ship?
Can i have parts breaking off and have it moving through space? I would love to see bits 'n pieces breaking off a capitalship when its in battle.
Can this all be done with the free version om gamestudio?
If anyone could give me some hints in how to approach the damage model and send me in the right direction, i'll try to put the pieces together
My code so far ( which is not all that much ):
Code:
#include <acknex.h> #include <default.c> #define STATE skill #define ELEVATION skill2 #define COOLDOWN skill4 ENTITY* PLAYER; // used to check the value on the c_move; var debugSkill3; function fire_missile(){ // the local vars var temp; my.ambient = 50; // medium bright my.lightrange = 300; // activate dynamic light vec_set( my.blue,vector(255,50,50)); // bluish light color set(me,BRIGHT); // additive blending vec_scale(my.scale_x, 0.5); // small size vec_for_bone(temp, you ,"main_missile_tube"); vec_set(my.x,temp) ; vec_set(my.pan,you.pan); me.pan = me.pan + 90; my.tilt = you.ELEVATION; while( 1 ){ c_move( my,vector( -10 * time_step , 0 , 0 ),NULL,IGNORE_YOU ); if ( HIT_TARGET ){ my.lightrange *= 1+0.5*time_step; vec_scale(my.scale_x , 1+0.5*time_step); // inflate size of the missile if (my.scale_x > 3) { ent_remove(me); // remove the missile after it has inflated to the max return; } } wait(1); } } function collision_event() { // Oops i hit, in this case, another capitalship ( capship3_mdl_000 ). if(event_type == EVENT_ENTITY) { // bring my entity to a halt. my.skill3 = 0; debugSkill3 = my.skill3; } } function move(){ my.emask |= ENABLE_ENTITY; //setting sensitive for collision my.event = collision_event; //assign the event-function my.skill4 = 1; while(1){ // assign the key combo's if(key_w) my.skill3 -= 0.1; wait(1); if(key_s) my.skill3 += 0.1; wait(1); if ( key_d ) //me.pan -= 2 *time_step; me.pan -= 5 *time_step; wait(1); if ( key_a ){ //me.pan += 2 *time_step; me.pan += 5 *time_step; wait(1); } if ( key_q ){ me.roll += 2 * time_step; my.ELEVATION = me.roll; wait(1); } if ( key_z ){ me.roll -= 2 * time_step; my.ELEVATION = me.roll; wait(1); } if ( key_space ){ if ( my.skill4 == 1 ) ent_create("missile.mdl",vector(me.x,me.y , me.z), fire_missile ); wait(1); my.skill4 = 2; } // after releasing the spacebutton, you will be able to fire the weapon again. // its not a gatlaingun. // TO DO: some kind of a delay() function for a 'cooldown' period. if ( !key_space ) if ( my.skill4 == 2 ){ my.skill4 = 1; } c_move (me, vector( 0, my.skill3 * time_step, 0), nullvector, GLIDE); debugSkill3 = my.skill3; wait(1); } } function main(){ //load the level level_load("spacetest2.wmb"); wait(2); // create the capitalship entity PLAYER = ent_create ( "capship2.mdl", vector( 500,3000,400), move ); // fixed camera position vec_set(camera.x, vector (-100, 3000, 450)); // capitalship capship3_mdl_000 is already placed in spacetest2.wmb }
Any comments or suggestions on my code are always welcome as i have no experience in this gamestuff whatsoever.
Ed.