Page 1 of 2

what

PostPosted: Sun Oct 16, 2011 3:57 pm
by Agusstosus15
what is the way to get animation name from getAllActorsInCollision? is this possible?

Re: what

PostPosted: Sun Oct 16, 2011 5:43 pm
by EvanBlack
Why would you want to do that?

I don't know about getting the animation name, but you can get the animation index or the animation position. Both are just as useful if not more.

That function returns an array of actor pointers, you just have to iterate through the array with a for loop.

Re: what

PostPosted: Sun Oct 16, 2011 6:17 pm
by Agusstosus15
to find animation name allow me to create actor i found that's why It would be very useful

Re: what

PostPosted: Sun Oct 16, 2011 7:21 pm
by EvanBlack
Make an array of all the animation names of the actor, then use the animation index to get the name from the array. You could do the same with all the actor names so you can just do this:

CreateActor(ActorNames[i], ActorAnimations[animationindex], ...)

Re: what

PostPosted: Sun Oct 16, 2011 7:39 pm
by Agusstosus15
i know that, but I have to got information about the actors inside the filled region actor
without that kind information i can't recognize the actor colliding with the filled region actor, so i can't created that specific actor, I'm not sure I'm make myself clear :(

Re: what

PostPosted: Sun Oct 16, 2011 7:55 pm
by EvanBlack
Make a char array holding all the animation names of a single actor

Get the actor's animation index from the colliding actor

Use the animation index to get the animation name from an Array


That is how you get the animation name from a colliding actor. But I still don't understand why you need the name when you can just use the index number. The index number is unique to the animation and is just as good as the name.

Ill make an example

Re: what

PostPosted: Sun Oct 16, 2011 8:13 pm
by Agusstosus15
and so, how to create actor using index of animation?

Re: what

PostPosted: Sun Oct 16, 2011 8:31 pm
by EvanBlack
char *getAnimName(int animIndex)

That function only get the animation name of the event actor.

That lets you get the animation name from the index, to get the index use: myActor.animindex




getAnimName: Get the name of an animation in Event Actor.
Return animation name if success, "" on error.

char *getAnimName(int animIndex)

animIndex: an animation index in the Event Actor.

Script Editor Syntax:
strcpy(text, getAnimName(0));

Re: what

PostPosted: Sun Oct 16, 2011 10:12 pm
by Agusstosus15
i want to get information of animname of all actors colliding with another filled region actor

Re: what

PostPosted: Sun Oct 16, 2011 10:34 pm
by EvanBlack
Code: Select all

Actor *ActorArray;
int NumOfColActors;
int i;
ActorArray = getAllActorsInCollision("Event Actor", &NumOfColActors);


for(i = 0; i < NumOfColActors; ++i)
{
    GlobalIndexArray[ActorArray[i].cloneindex] = ActorArray[i].animindex;
}


This code gets the animindex of all the colliding actors but doesn't store it. You would need to create a global array to store the animation names or indexs for later use. To get the names you would either have set an event inside each actor so when they collide with the region they send their Animation Name to a Global Variable or Array for each Actor. If you are using clones then you only need to do this for the main actor and each clone will have the event. Otherwise you need a function that does something and send the animation name to it. But right now you haven't given enough information to tell you how to do what you need to do.


If you are using clones the event would look like this:

MyActor->Collision (Any side of Region) -> Script Editor:
Code: Select all
GlobalAnimNameArray[cloneindex] = getAnimName(GlobalIndexArray[cloneindex]);


But even this code probably won't work because it has to happen in a specific order.

Re: what

PostPosted: Sun Oct 16, 2011 11:35 pm
by Agusstosus15
int n;
Actor *actors;

actors = getAllActorsInCollision("Event Actor", &n);



int i;
for(i = 0; i < n; i++)
{
createActor(actor[i].clonename, getAnimName(getAnimIndex(actor[i].clonename)), ....position i want
}
}
will crteate me all actors in collision at position i want?

Re: what

PostPosted: Sun Oct 16, 2011 11:54 pm
by EvanBlack
No.

you can't use a clone name to create an actor.

You also can't use getAnimName() like that, it will only get the animation name of the event actor, in this case the region. You need a global char array that would hold all the animation names of all your clones based on the clone index. Which means a 2D character array.

Example: if clone one has animation name of Anim1

GlobalAnimNameArray[1] == "Anim1"

You can initalize a Global Character Array for your animations as such:
Code: Select all
int NumOfClones = 3;

GlobalAnimNameArray[NumOfClones][32];

GlobalAnimNameArray[0] = "Anim0";

GlobalAnimNameArray[1] = "Anim1";

GlobalAnimNameArray[2] = "Anim2";


You also need a parent actor. This one uses the colliding actor as the parent.
Code: Select all
CreateActor(actors[i].name, GlobalAnimNameArray[actors[i].cloneindex], actors[i].clonename, "no Path", 0, 0, false);

Re: what

PostPosted: Mon Oct 17, 2011 12:56 am
by Agusstosus15
when I initiate Global the array still be exist when the event is over?

Re: what

PostPosted: Mon Oct 17, 2011 1:16 am
by EvanBlack
Use global script and initiate the global array there.

The button at the top Script

then go to Global Code

Type in your array.

Name your script and click Add.

Re: what

PostPosted: Mon Oct 17, 2011 1:44 am
by Agusstosus15
why you didn't place a second dimension of array?