Post by someonewhoask on Apr 5, 2024 12:57:25 GMT
How i can change the order of Scprits's Object Handles?
I have many skinmesh(enemys) scattered in the map, all associeted with one script, and the script are associeted with a rigidbody sphere, and a 1st person camera(for knowing the player's position), and ValuePrint(for write total number of enemys).
The script control every single move of every skinmesh(enemys) the problem is, the funtion "iObjectHandle()", this is what i need for controll every enemys in the map(direction, position, ecc...) but if i dont have all SkinMesh Handles one after other just dont work, and i don't know if is possible to change the order of Object Handles!
the scpript in question:
I have many skinmesh(enemys) scattered in the map, all associeted with one script, and the script are associeted with a rigidbody sphere, and a 1st person camera(for knowing the player's position), and ValuePrint(for write total number of enemys).
The script control every single move of every skinmesh(enemys) the problem is, the funtion "iObjectHandle()", this is what i need for controll every enemys in the map(direction, position, ecc...) but if i dont have all SkinMesh Handles one after other just dont work, and i don't know if is possible to change the order of Object Handles!
OBJECT HANDLES
OBJ_0 | Cam1StPerson |
OBJ_22 | SkinMesh (<- the problem in question, how i move it?) |
OBJ_66 | ValuePrint |
OBJ_88 | === Group : Enemy ==.... (this exist for make order...) |
OBJ_110 | RigidBody : sphere |
OBJ_132 | SkinMesh |
OBJ_154 | SkinMesh |
OBJ_176 | SkinMesh |
the scpript in question:
const int MAX_ENEMYS = 512;
int num_enemys;
Vector3 []enemys_pos (MAX_ENEMYS);
Quaternion []enemys_dir (MAX_ENEMYS);
Vector3 []enemys_speed (MAX_ENEMYS);
int []enemys_type (MAX_ENEMYS);
Vector3 player_pos;
void Main()
{
if(iInitializing())
{
num_enemys = iObjectHandle(-1) - 4; //-1 for the Group,
//-1 for the ValuePrint,
//-1 for the RigidBody,
//-1 for the player
if(num_enemys < MAX_ENEMYS)
{
OUT_66 = num_enemys;
iObjectImpostersCreate(OBJ_110,num_enemys);
for(int i = 0; i < num_enemys; i++)
{
iObjectLocation(iObjectHandle(i + 4), enemys_pos[i]);
iObjectOrientation(iObjectHandle(i + 4), enemys_dir[i]);
enemys_speed[i] = Vector3(0, 0, 0);
enemys_type[i] = 0;
iObjectImposterSet(OBJ_110, i, enemys_dir[i], enemys_pos[i] + Vector3(0, 0.5, 0));
}
}
else
OUT_66 = -1;
}
//control movment
for(int j = 0; j < num_enemys; j++)
{
iObjectLocation(OBJ_0, player_pos);
enemys_dir[j] = lookTarget(player_pos - enemys_pos[j]);
iVectorRotate(enemys_speed[j],Vector3(0, 0, 3),enemys_dir[j]);
}
//apply movment
for(int u = 0; u < num_enemys; u++)
{
iObjectLocationSet(iObjectHandle(u + 4), enemys_pos[u] - Vector3(0, 0.5, 0));
iObjectOrientationSet(iObjectHandle(u + 4), enemys_dir[u]);
iObjectImposterVelocitySet(OBJ_110,u, enemys_speed[u]);
iObjectImposterGet(OBJ_110,u, enemys_dir[u], enemys_pos[u]);
}
if(iDeinitializing())
{
iObjectImpostersDestroy(OBJ_110);
}
}
Quaternion lookTarget(Vector3 delta)
{
Vector3 norm;
Quaternion enmy_orient;
iVectorLengthSet(norm, delta, 1.0f);
norm.y = 0;
iQuaternionLookAt(enmy_orient, norm, Vector3(0, 1, 0));
//iObjectOrientationSet(OBJ_0, enmy_orient);
return enmy_orient;
}