Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
ccbSetAnimationFromSceneNode works weird

dekon_17
Registered User
Quote
2023-09-21 19:46:33

Since there is no way to reload the model AND it's animations, I had to use this cool new command "ccbSetAnimationFromSceneNode". Thing is, however, it works in a weird way. So, when the enemy is spawned, its animations is set like that:
ccbSetSceneNodeProperty (node, "Looping", true);
ccbSetAnimationFromSceneNode (node, this.AnimNode, "Idle" + Math.ceil (Math.random() * 2));
And it works fine, idle animation plays like it should. Problems, however, started to arise with other animations. When the player gets spotted by enemy, the following part happens:
if (this.NotAlerted)
ccbSetAnimationFromSceneNode (node, this.AnimNode, "Alert" + Math.ceil (Math.random() * 2));
else
ccbSetAnimationFromSceneNode (node, this.AnimNode, "Aim");

For some reason, however, it starts playing standart "All" animation. Animation name is correct, since, well, something started playing, which doesn't happen when animation with given name doesn't exist. So, instead of enemies panicing from seeing the player, they aim, panic, and if I would make their panic time long enough, they will panic once again (because of two panic animations), then die three times in different ways. Same happens with most other cases. I say most, because they actually die with no issues - the required animation plays:
this.DeathAnim = Math.ceil (Math.random () * 3);
ccbSetAnimationFromSceneNode (node, this.AnimNode, "Death" + this.DeathAnim);

One thing to note here is that idle animation is set at the start of the script, and the death animation is actually the state 0 of a "switch" loop:
There is supposed to be the whole "switch" thing, but the forum just cuts it off for some reason, even though it's under the limit. Basicaly, death animation is in case 0, alert and aiming animations are in case 3, shooting in 4, running in 5. As I mentioned, only idle and death animations are working fine. If you REALLY want to look at this mess (or steal some parts of it), it's here:https://github.com/Dekon17/Some-... starting from line 67

What am I doing wrong? Are there some dependencies for this command? I tried using it with "Execute JavaScript", everything went well.


okeoke
Registered User
Quote
2023-09-21 20:23:35

Hi Dekon_17,

You github repo seems to be private - direct link leads to 404 page, you profile says you don't have any public repositories.

Aside from that, I wouldn't use ccbSetAnimationFromSceneNode at all, since performance-wise it's much worse than setting animation regular way.


sven
Registered User
Quote
2023-09-22 08:54:51

I have problems with this function also.
It sets animations for all clones..

I have zombie0 zombie1 zombie2
If i want to take animation from zombie0 and put it to zombie1 ..zombie2 will be affected also.


just_in_case
Moderator
Quote
2023-09-22 11:12:23

Thanks fro reporting I will look into the API and will let you guys know if there is anything that's need to be updated.


dekon_17
Registered User
Quote
2023-09-22 18:02:56

Well, okeoke, I changed it to public. Too bad there's no way to make it accessable only with link, kind of worried because of this.

Though, as you've mentioned, this command is not really performance-friendly. If so, then... Well, guess I'll have to manually set animations for models or something, which is quite bad. You know, performance is something that I desperately try to manage in my game (to not much success, sadly). So, I will try to use standart "ccbSetSceneNodeProperty" then.


just_in_case
Moderator
Quote
2023-09-23 08:45:11

Just an update on the function after testing it, didn't noticed any performance issue with it as it is simply using the exisiting armature data and is not doing anyhting else.

@sven regarding the animations gets applied to clone, yeah it will also get applied to clone. Because CopperCube uses singel armature for one model, and then simply create an instance of it for animated model.

That way all the clones uses same armature instead of having multiple armatures.

So you have to import the model with a different name, so that there will be a new armature for the model. You can check how many armatures you have in your game by going into the animation editor and at the top you will see the dropdown of the armatures for the model.

So when you create a clone of an animated mesh, you won't see any new armature for it. Will see if I can fix that in the source, so that it will create a new armature, maybe by adding a bool parameter to it, so that you can specify wether you want to create a different armature for clones or not.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internationa?" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact