Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
So, I continued creating my WebGL game. And because the enemies there are infected, I started creating my own AI, since the standart AI of CopperCube is not suited well for them. I want to make them follow player always (standart AI will move from one point to another one, and if player moves, then AI will have to reach its destination point, realise that the player left the area and then try to get close to him again). The problem I stumbled in is that I don't exactly know how to register any hits on it with standart "Collide when moved" behavior. Do anyone know something about that? Like, how to make this? |
||||
|
are you talking about making the AI always follow player and attack when close if you are you could use follow node script and (on proximity on income) of player stop and start to attack you if player moves the AI (on proximity on exit) start to follow again |
||||
|
Can't say that I really understood you, coa, but I already made a bit different choise. I think that I can use "ccbAICommand" to do the things I want to. Still, maybe your method could be good as well. |
||||
|
Okay, I was able to make enemy follow player everytime, but the attack doesn't work, I guess. I tried to do this in the behavior: var posT = ccbGetSceneNodeProperty (this.ToAttack, "Position"); My only idea is that enemy can't hurt me because he tries to attack every frame, so, he can't land a single hit in this short time. Am I... Right? |
||||
|
Yes you are right. My solution might feel a bit weird but you can give it a try. 1.) Make an action that will make the scenenode attack your character. 2.) Attach a behavior making the scenenode call an action in a regular time interval. 3.) In the script you wrote above, instead of calling the attack command make it set a coppercube variable to 1, and in the else along with what you put there set the variable back to 0. 4.) Then in the behavior attached in no. 2. ad a condition action(i.e if variable = this) Saying if the variable created above is equal to 1, then call the attack action created above I hope this works |
|