Hi Leute,

ich möchte gerne diese Sample Flagge aus dem prefab Ordner nutzen. Sie funktioniert auch prima. Aber ich verstehe den Code überhaupt nicht. Meine Frage an die Experten: wie melde ich diese Flagge korrekt wieder ab? Denn wenn das Level ein zweites mal geladen wird, stürzt das Spiel ab. Mit ner Physik Fehlermeldung.

Hier der Code:
Code:
function init_flag()
{	
	// generate flag pole	
	//	ENTITY *pole = ent_create(CUBE_MDL,vector(0,0,20*8),NULL);
	pole = ent_create(CUBE_MDL,vector(0,0,20*8),NULL);
	vec_set(pole.scale_x,vector(0.5,0.5,40));
	vec_set(pole.pan,vector(0,0,0));
	vec_set(pole.blue,COLOR_WHITE);
	set(pole,SHADOW|CAST);
	pXent_settype(pole,PH_STATIC,PH_BOX);

	// generate flag
	//	ENTITY *cloth = ent_create("clothflag.mdl",NULL,NULL);
	cloth = ent_create("clothflag.mdl",NULL,NULL);

	vec_set(cloth.pan,vector(0,0,0));
	cloth.material = mtl_twosided_alpha;
	cloth.ambient = 40;
	set(cloth,SHADOW|CAST);
	set(cloth.material,PASS_SOLID); // required for shadow
	
	// attach flag to pole
	c_setminmax(pole);
	c_setminmax(cloth);
	vec_set(cloth.x,vector(
	pole.x,
	pole.y+(cloth.max_y-cloth.min_y)/2,
	pole.z+pole.max_z-(cloth.max_z-cloth.min_z)/2));
	
	// setup flag cloth	
	var cloth_options[40];
	memcpy(cloth_options,CLOTH_DEFAULT,40*sizeof(var));
	vec_set(cloth_options[25],vector(-10,20,0));  // external acceleration
	vec_set(cloth_options[28],vector(5,10,5));  // random wind acceleration
	cloth_options[9] = 4; // Tear Factor
	cloth_options[37] |= NX_CLF_GRAVITY|NX_CLF_BENDING|NX_CLF_COLLISION_TWOWAY|NX_CLF_SELFCOLLISION|NX_CLF_TEARABLE|NX_CLF_BENDING_ORTHO;
	
	pXent_cloth(cloth,pole,NX_CLOTH_ATTACHMENT_TWOWAY,0,0,cloth_options);
}



Habs damit versucht, aber das wars noch nicht:

pXent_settype(pole,0,0);
ptr_remove(pole);
wait(1);
pXent_settype(cloth,0,0);
ptr_remove(cloth);
proc_kill((void*)init_flag);
wait(1);