Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hi guys, I'm using the AI Agressive behavior for the enemy, but when the enemy die, he do the "die animation" but come back alive and continues shooting! The enemy need to die and stay died! Any idea? I think the script Ai agressive continues working and shooting when the enemy is died. Thanks! |
||||
|
This usually happens to me if call ccbAICommand on a dead enemy. To prevent this I do the following: 1. Built-in actor behavior has "on death" action property - add there an action which reads enemy node name, and then sets a variable with name like enemyNodeName + '_is_dead'. Set its value to 1 (I believe, booleans do not work with ccbSetCopperCubeVariable); const enemyNodeName = ccbGetSceneNodeProperty(node, 'Name'); 2. Add ccbGetCopperCubeVariable(enemyNodeName + '_is_dead') check to top of your custom AI behavior onAnimate function, which interrupts onAnimate execution in case it's set to 1: behavior_YourAI.prototype.onAnimate = function (node, timeMs) { This also can happen in case you have some scheduled actions like doLater or setTimeout or something similar to control the AI. You need to add similar checks to these too. |
||||
|
Thanks okeoke, I aprecciate your help, I will try! |
||||
|
Okeoke, can you please elaborate on how you corrected the enemy ai you mentioned above, I don't really understand much of coding but I really need to do this, if possible provide a ccb, Thanks |
||||
|
I think I can try. Can you share ccb or tell how your enemies are set up? |
||||
|
Oh yeah, sorry for late reply, actually my enemies are being cloned after a number of enemies are killed, and the process keeps going like that, is there any info you want me to provide on this |
||||
|
I don't think cloning could cause that issue. Are you using some custom behavior or regular actor script? Also do you clone from a node which doesn't change over time, i.e. it's not active in game. Could it be that you're cloning already dead enemy? Also do you set a unique name for each enemy? |
||||
|
I have the same problem as andgameplay but I only wish you further explain your approach to me |
||||
|
Ok, I believe this is something that happens in case you execute ccbAICommand function on enemy which is already dead. It seems like in this case command is executed no matter if enemy is dead or not. The idea is to prevent ccbAICommand from being executed, so you need the script to stop before it reaches ccbAICommand line. For that you on as enemy dies you set enemyName + "_isDead" variable to 1. Inside enemy script you check for enemyName + "_isDead" variable every time it is executed. If it's equal to 1, you stop execution by calling return. |
|