3 registered members (NnamueN, Akow, 1 invisible),
1,421
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Managing 40 created entities
#248895
01/29/09 21:13
01/29/09 21:13
|
Joined: Jan 2009
Posts: 86 Brasil - RS
DiegoFloor
OP
Junior Member
|
OP
Junior Member
Joined: Jan 2009
Posts: 86
Brasil - RS
|
Hi! I have an entity that creates other 40 entities. But the problem is that there's no way to differentiate them, to manipulate each one individually. I tried associating a function, instead of an action, to the created entities, so I can sue it as some sort of tag. But it's not possible to call the function when creating the entity. Maybe with the code will be easier to understand. Bellow are the action of the pivot entity, and the function associated with the newly created entities. action pivot()
{
VECTOR finalvector;
VECTOR tempvector;
var i = 0 ;
var j = 0 ;
phent_settype (me, PH_RIGID, PH_SPHERE); //physics..
phent_setmass (me, 3, PH_SPHERE);
phent_setfriction (me, 80);
phent_setdamping (me, 40, 40);
phent_setelasticity (me, 100, 50);
//adjusting the position for the new entity
vec_set (tempvector , vector(0,0,100));
vec_set (finalvector, tempvector);
vec_add (finalvector, my.x);
ent_create ("triang.mdl", finalvector, pontosmoveis); //first (top) triangle created
//adjusting position again
vec_rotate(tempvector, vector(0,180,0));
vec_set (finalvector, tempvector);
vec_add (finalvector, my.x);
ent_create ("triang.mdl", finalvector, pontosmoveis); //bottom triangle created
//the following loop creates all the triangles left
while (i<5)
{
i+=1;
vec_rotate(tempvector, vector(0,30,0));
vec_set (finalvector, tempvector);
vec_add (finalvector, vector(my.x, my.y, my.z));
while (j<8)
{
j +=1;
ent_create("triang.mdl", finalvector , pontosmoveis);
vec_rotate(tempvector,vector(45 ,0 ,0));
vec_set (finalvector, tempvector);
vec_add (finalvector, vector(my.x, my.y, my.z));
}
j=0;
}
}
function pontosmoveis(indice)
{
VECTOR range;
vec_set(range, vector(-10,10,0));
phent_settype (me, PH_RIGID, PH_SPHERE);
phent_setmass (me, 1, PH_SPHERE);
phent_setfriction (me, 80);
phent_setdamping (me, 40, 40);
phent_setelasticity (me, 50, 20);
pivotobj = phcon_add(PH_SLIDER, me, you); //pivotobj is a previously defined pointer
phcon_setparams2(pivotobj, range, nullvector, nullvector);
while(1)
{
if(key_z)
{
vec_set(strength, vector(1000,10000,0));
}
if(key_x)
{
vec_set(strength, vector(-1000,10000,0));
}
if(!key_z && !key_x)
{
vec_set(strength, vector(0,0,0));
}
phcon_setmotor(pivotobj, strength, nullvector, nullvector);
phcon_setmotor(pivotobj, strength, nullvector, nullvector);
wait(1);
}
} edit: There's another problem I forgot to mention! Aparently, this lines: phcon_setmotor(pivotobj, strength, nullvector, nullvector); phcon_setmotor(pivotobj, strength, nullvector, nullvector); Only influence the last entity created.
Last edited by DiegoFloor; 01/29/09 21:16.
|
|
|
Re: Managing 40 created entities
[Re: DiegoFloor]
#248913
01/30/09 00:07
01/30/09 00:07
|
Joined: Apr 2006
Posts: 737 Ottawa, Canada
Ottawa
User
|
User
Joined: Apr 2006
Posts: 737
Ottawa, Canada
|
Hi! You can give each entity a number in skill[5] in WED Then in your code If (skill[5] == 2) ..... Ottawa
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|