Hello everyone, today I wanted to ask if it is possible to rename animations loaded with a actor or loaded through loadAnims? I have checked the manual and looked though the forums and found nothing.
Many thanks to any offers of help.
Hello everyone, today I wanted to ask if it is possible to rename animations loaded with a actor or loaded through loadAnims? I have checked the manual and looked though the forums and found nothing.
Many thanks to any offers of help.
When you load an Actor, you should be able to explicitly specify the names that you want. Something like this:
Given the following files:
myActorModel.egg
myActorModel-walk.egg
myActorModel-stand.egg
You can potentially do something like this, if I recall correctly:
self.myActor = Actor(
"myActorModel",
{
"run" : "myActorModel-walk",
"stand" : "myActorModel-stand",
}
)
The “walk” animation will now be accessed instead as “run”, while the “stand” animation will still be called “stand”.
I wanted to rename a already loaded animation of a already loaded actor.
Ah, I see.
Hmm… I don’t know, offhand.
Based on a quick look at the API, what happens if you call “loadAnims” on your Actor, providing the new names? (I don’t know whether it would be called for to call “unloadAnims” first, to clean up the old animations.)
Well that is just it, I think I am having issues with loading a animation that I previously unloaded, and thought I can go around the issue by simply renaming the animation something else instead of unloading the animation.
It is my cutscene feature, what it does is shifts between two animation names “RoleA” and “RoleB”, so that one can play while the other is cleared, back and forth when ever a new animation egg file is called.
All you have to do is re-initialize the actor with the new names.
I suppose that my question is that of why you’re unloading the animations–can you perhaps just leave them loaded, and then just call the same animation again?
Originally this method allowed a infinite amount of possibilities, and prevented the actor from getting too bloated from animations, but let me test your suggestion right now, sorry I am a little tired, give me a few.
Not a problem! Tiredness can very much slow one down, I do think! And in all fairness there’s no hurry on my end, so take your time.
But do you in practice need quite so broad an array of possibilities?
@Thaumaturge Your solution works! and solves my issue, however the topic is about asking if animation names can be changed, should I change the topic of the thread so I can mark your post as the answer? in the time being I will still attempt to get this question asked.
@panda3dmastercoder how do you re-initialize the actor? are you suggesting removing it first then reloading it again?
I’m glad that the solution worked for you!
Personally, I wouldn’t worry too much about the thread-title. The contents may help people to find it in the future, perhaps, and the solution is the solution, regardless of the title.
yeah, but I am sure someone looking for how to change the name of a animation will get disappointed if they find this, if I change the title to say “load animations consecutively” it would be better.
Perhaps, although part of the answer to their question might be that it’s not simple.
@Thaumaturge okay, fair enough, I marked your post as the solution, thanks for the solution to my problem.
@panda3dmastercoder I also wanted to thank you for your insight as well.
To re-initialize an actor:
self.actor = Actor(model, anims)
self.actor.__init__(model, anims)
EDIT: You might have to remove the actor’s node before doing so.
Please don’t do that! That is a terrible hack, classes are not designed to be used that way, and there may be many subtle side-effects from trying that.
In that case we can just do so:
self.actor = Actor(model, anims)
self.actor.cleanup()
self.actor.removeNode()
del self.actor
self.actor = Actor(newModels, newAnims)
okay, thanks, though for curiosity sake, I wonder if there is a simple call for renaming animations without reloading the egg file, you know to make it more easier on the drive.
You could make a function which carries out the whole process, and just call the function every time.
yeah that is a option, but it would still be reloading from the egg/bam file again, I guess I does not matter, but still a little surprising there is no simple call for renaming animations seeing that there is one for nodes.