Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hi, Recently I decided to look into AI freezes on attack issue, and try to figure out if it's possible to somehow make a workaround for it. So I came to the following conclusions: Cause: The issue happens in case attack animation frame speed is too high (> 30), which is always the case with FBX, since it's multiplied by 10 on import to CopperCube. How do you know you have the same issue as I do? 1. Set actor AttackAnimation to None and see if the actor still freezes; 2. Set attack animation speed to 30 and see if it still freezes (use scene node clone as bullet instead of direct hit, so it's more noticeable, since it will be slow); If behavior doesn't freeze anymore - it's the same issue; What happens? Attack animation plays until the last frame, but ActionOnAttack is never called, so the node "stucks" on the last attack animation frame and action on attack never gets executed. What have I tried I tried to workaround this by detecting the last animation frame and then cancel attack, and invoke attack action using a custom behavior. Unfortunately, this only works partly - shoot action doesn't work properly in case it's called not from an actor behavior. I tried to vary animation fps programmatically, so it becomes lower by the time animation ends (silly attempt) that didn't work as well. I tried to vary animation length and fps, freeze also seems to be fixed in case animation is 10-20 frames in length with 300 fps. How to fix There is no quick fix for it, since it actually looks like a CopperCube bug. I don't own a studio version, and I don't know what are ActionOnAttack trigger conditions, but it seems like they somehow never met. You can: 1. Convert your model to .x, since it imports properly. I never had any issues with .x models before; 2. Use custom actor behavior, which plays an attack animation without using ActionOnAttack; 3. Remove attack animation at all or make it very short and set it to 30 fps; Since this is the announcement section, I will also announce my CopperCube forum bingo card for 2024 here:https://copperbingo2024.000webho... My plan is to look into as many of these issues is possible and try to resolve at least some of them. |
||||
|
I second that, never knew about the .x format working better, will have to try it out. For me, working with .fbx formats, I don't select any animation for "attack animation" In the "action on attack", i choose "change animation of scene node" and select my attack animation, worked out fine with my imported models. But yes, the attack animation needs to be very short. |
||||
|
It also seems like the AttackAciton is not triggered on the last frame of the animation. I have attack animation from 1690.0 to 2040.0 with 300 fps. If I run it with 30 fps it's triggered on frame 1840. With 25 fps it's 1799, so it might be that attack action is simply triggered inside some sort of frame interval, which sounds a bit weird to me. But in this case if animation fps is too high, it simply skips the required interval, and attack actions never gets triggered. @jctech Thanks for the tip, this also could be a workaround. update: If I set animation fps to 45, the action is executed on the last frame 2040. This actually happens to all animation fps up to 60. So the new theory is that with high animation fps it just expects the frame beyond the animation length to trigger the attack event, which never happens. |
||||
|
yes this is a Coppercube bug :- Actually it waits for 500 ms tick for the animations but for attack animation it checks for the animation time for the ticks instead of 500 ms. And lets say when you have a 1000 frames for your attack animation and the animation speed is 300FPS, it will wait for 300*1000 ms which is about 5 minutes I guess. In your case it can be different, so yeah it seems that it never executes the attack action, but it does on a scale of longer duration. So when we changed the FPS to 30 it waited for 30 seconds and performed the attack and did all the stuff, and worked like that. So it is not related to .x format or .fbx format, it is related to the amount of frames for the animations and the FPS for that animation. But yeah a custom behavior can be made for this that will check for the frame number instead of timer tick, if the attack animation gets completed then complete the action on attack thing. yeah, it can be improved in the C++ source too, but it's better to create an open-source custom AI behavior in Javascript. btw, nice website hehehe, you got some pretty interesting threads there. ![]() |
||||
|
Thank you for the clarification:) Extension was also my first idea, but the issue is shoot action. It behaves differently if you invoke it from actor behavior vs if you invoke it from a js behavior. For some reason with default setting "shoot from which scene node" set to "camera or current scene node", it still acts like "active camera" is selected, node the scene node. Can you suggest something on this? |
||||
|
how are you invoking the shoot action, are you feeding the current node (AI) as the second arguement to the command ? ccbInvokeAction(actionId, currentNode)or you are using it without the second arguement? If not then try providing the AI as current node for the shoot action and check if it detects the scenenode or let me know if it still shoots from the active camera and not the scenenode. |
||||
|
Yes, I believe, I provide the node as a second argument. It still doesn't work as expected. |
||||
|
Well, setting ShootingFromWhichSceneNode in combination with checking ShootToCamera target is sort of works! For me now it sometimes runs shoot action multiple times instead of only one, but I think this is fixable. Also not sure if cloning the node will work as expected, I suppose - no. |
||||
|
Well, ok. It works and cloning works too! There is some specific setup to it: Extension code: // The following embedded xml is for the editor and describes how the behavior can be edited: I'll create an itch page for that and upload demo and extension there. Thank you for the help, JIC. |
||||
|
Glad that it worked out for you, I actually have a custom Shoot and AI behavior, but I limited that for 2D games specifically. Maybe I will create a 3D version of it as well in future, btw the setup to shoot at the current camera will only work for FPS games, and It won't work that much better if someone is going to create a TPS game. I think the inbuilt behaviors and actions also need some updates. The change position action should have a boolean that will check if we want to change position with collision or not. Shoot action should have an option to shoot at a specific target or AI. I don't know why but instead of expanding or updating the C++ source, I think it's better to create custom extensions for them. You should also dive into the C++ source code you will find it interesting how many things you can do with the source code. I highly recommend it. |
|