Well the storing of an actor name and variable is meant for getting an Actor* of the given actor. You could set up an actor char array, to hold all the actor types, and then one for the proper cloneindex for each, but I don't think this is optimal given what you want.
Just checking, have you tried using parent? I know using parenting for things like this is not always the best method, but you can make your units the parents of all of the following actors. If not, then you can also use creator, either of these allows you to do this.
- Code: Select all
parent.x=100;
collide.x=100;
This does exactly like it looks, but if this kind of actor variable referencing is still not what you need, as it might not fit in the system you are using right now, then you can always use the method I suggested before. To do that, you would need to place this function into global code.
- Code: Select all
Actor *
getCloneIdx (const char *cname, int cindex) //g_GetCloneByIndex, its original name
{
char buffer[50];
sprintf(buffer,"%s.%i",cname,cindex);
return(getclone(buffer));
}
Then if you have your actor variable string array, then you can put each required actor name into the array, and upon creation, you can set the cloneindex into a corresponding int array. Whenever you want to access an actors variables, you would do something like this.
- Code: Select all
Actor* healthActor = getCloneIdx(nameStorage[0], indexStorage[0]);
healthActor->x = 100;
If you are going to do something like that, I would either define what each part of the array is, with either #define, or enum. That way you can easily track which actor you are getting. If this didn't make sense for any reason, I can explain it more in depth, or post a demo showing it. I don't know what you have already done for creating the units and following actors, so I can't say what would be the best method given the circumstances.