Page 1 of 1

Accessing Actors Dynamically

PostPosted: Thu Feb 21, 2013 3:17 am
by bamby1983
I have a scenario where I store the cloneid of an actor in a variable and then later need to use this value to check the animindex of this first actor. This check is done when I click on another actor with clones, so unless I'm mistaken, getClone won't work here.

I can use sprintf to get the exact actor name (including the cloneindex within it) into a character string, but how do I use this character string to check the animindex of the actor. I can't use the dot operator as it would try to check the animindex property of the strong and not the actor itself, which throws an error.

Would anyone please be able to let me know whether there is a way by which I can find the animindex of an actor using the above string?

Re: Accessing Actors Dynamically

PostPosted: Thu Feb 21, 2013 3:42 am
by skydereign
getclone can use clonenames. And clonename is the name of the actor with the cloneindex attached. So you can use getclone.
Code: Select all
char buffer[30];
int index = 5;
int a_index = -1;
sprintf(buffer, "someactor.%d", index);
a_index = getclone(buffer)->animindex;

Re: Accessing Actors Dynamically

PostPosted: Thu Feb 21, 2013 3:46 am
by bamby1983
Thanks Sky! You are awesome!