Comment faire aller et venir l'ennemi?

Salut.
Mon objectif est de rĂ©soudre un petit problĂšme, j’ai parcouru des tutoriels sans fin, refait les Ă©vĂ©nements plusieurs fois, mais l’ennemi Angie (bleu) ne patrouille toujours pas dans les deux directions. Lorsque la scĂšne s’ouvre, elle se dĂ©place avec son animation “Droite” vers l’obstacle “Aller Ă  gauche” et y reste (elle s’approche du personnage jouable argentĂ© quand il se trouve Ă  portĂ©e). Personne dans les forums ne m’a aidĂ© Ă  rĂ©soudre ce problĂšme. La seule personne qui a Ă©tĂ© utile (avec un problĂšme prĂ©cĂ©dent) Ă©tait MrMen. AprĂšs que personne n’ait aidĂ© Ă  rĂ©soudre mon problĂšme, j’ai suggĂ©rĂ© de tĂ©lĂ©charger le projet sur mon Google Drive, afin que quelqu’un puisse entrer dans le projet, pouvoir tout voir et repĂ©rer le problĂšme. Ce que je veux, c’est que le personnage ennemi (bleu) fasse des allers-retours (ou mĂȘme simplement inactif), et utilise ses autres animations. Je suis artiste et animateur. Je n’ai pas l’intention de devenir dĂ©veloppeur. Je veux juste faire ce jeu de mon concept de science-fiction.
FB page for game

Vous avez une boucle infinie dans le cadre rouge.

Lorsque Angie à vu l’autre personnage elle va le voir.
Et quand Angie est proche du personnage vous laissez Ă  1 la variable seeyou que vous utilisez dans l’évĂšnement au dessus. Donc Angie tourne infiniment en rond autour du personnage.
Changez seeyou = 0 pour que Angie ne soit pas attiré vers le personnage quand elle est déjà à cÎté.

1 Like

Salut. J’avais oubliĂ© qu’en plus de MrMen, vous Ă©tiez Ă©galement utile dans les forums anglais. Je m’excuse. Le principal problĂšme que j’ai est que Angie, ennemie bleue, ne fait pas de va-et-vient entre les obstacles “GoLeft” et “GoRight”. Le problĂšme secondaire est que, pendant tout cela, elle n’utilise que son animation «Right». Sur la base de votre suggestion concernant les nombres utilisĂ©s avec la variable «seeyou», j’ai essayĂ© les 4 possibilitĂ©s. Tels Ă©taient les rĂ©sultats. 1,0 Angie dĂ©mĂ©nage Ă  GoLeft et y reste. Quand le personnage jouable argentĂ© Kristi s’approche, Angie se dirige vers elle. Kristi peut s’échapper lorsqu’elle atteint une certaine distance. C’est vraiment bien, sauf qu’Angie utilise toujours son animation de marche Ă  droite.
0,1 Angie se dirige immédiatement vers Kristi, puis fait des allers-retours entre Kristi et GoRight.
0,0 et 0,1 sont complĂštement faux. Donc, pour revenir Ă  essayer de faire passer l’ennemi bleu Angie entre GoLeft et GoRight, puis aller voir Kristi quand Kristi s’approche, pour le moment, je n’ai que la variable “seeyou” sur Angie, valeur “0”. Est-ce correct? D’autres suggestions? J’ai le sentiment que quelqu’un a besoin d’entrer dans le projet, oĂč il peut tout voir, et saura alors pourquoi Angie ne traverse pas entre les deux obstacles et n’utilise qu’une de ses animations. De plus, mon projet se charge dĂ©jĂ  trĂšs lentement, j’ai tout optimisĂ©, et je n’ai mĂȘme pas ajoutĂ© les animations pour le personnage AI dans la scĂšne 2 et la scĂšne 3.

Vous avez des animations dans le personnage, une animation vers la gauche et une autre vers la droite.
C’est bien, mais dans ce cas vous ,n’avez pas besoin de faire un “flip” sur le personnage.
L’action “flip” est utile pour retournĂ© l’objet si vous n’avez pas d’autres animations.

Faut faire un choix entre “flip” ou les animations.

Quand je change les “flip horizontal” en “no”, ou que je supprime les “flip horizontal”, Angie va toujours immĂ©diatement au “GoLeft” et y reste. La seule diffĂ©rence est que maintenant elle fait son animation de marche Ă  gauche au lieu de sa marche Ă  droite. Je ne pensais pas avoir la possibilitĂ© de supprimer ses animations au lieu des flips, tout comme j’aurais aimĂ© gagner de la place, car elle aura besoin des animations pour chasser le personnage jouable, n’est-ce pas? Qu’ai-je manquĂ© pour qu’Angie n’ait jamais fait des allers-retours entre les obstacles comme prĂ©vu? Ai-je une mauvaise direction quelque part? Il me semble qu’il ne devrait pas y avoir seulement la variable “see you” sur Anjie mais quelque chose d’autre. Puis-je lui ajouter une autre variable comme “Direction_Left” ou “Left_0”?

Si la position d’Angie sur l’axe X est plus petit que la position de Silver alors met l’animation Right.
Si la position d’Angie est plus grande tu met l’animation Left.

En résumé Angie est à gauche de Silver tu met son animation Right pour la faire face à Silver qui est à droite.
Et l’inverse pour l’autre cĂŽtĂ©.

Ne réfléchi pas avec des variables.
Réfléchi de ce dont tu a besoin. Tu regarde la situation, et tu réfléchi à ce qui ne va pas. Ne te lance pas dans des trucs compliqué rapidement.
Fait un Ă©tat de la situation avant d’agir.

Rebonjour!
J’ai renoncĂ© Ă  essayer de faire traverser l’IA ennemie Angie entre les deux obstacles, car cela retarde trop le jeu et utilise trop de temps pour les gens. J’ai maintenant Ă  la fois un behavior de pathfinding et de topdown sur Angie, comme je l’ai rĂ©cemment vu dans un tutoriel. Quand la scĂšne s’ouvre, Angie fait idle, ce qui est bien. Je crois que lorsque le personnage jouable Kristi s’approche d’elle, Angie ira attaquer Kristi. Le problĂšme maintenant est que, dĂšs que je dĂ©place Kristi, Angie imite son comportement. Je n’ai aucune idĂ©e de pourquoi cela se produit. Comment m’en dĂ©barrasser? J’ai fait une vidĂ©o rapide et l’ai liĂ©e, afin que vous puissiez voir le problĂšme en action.
Merci


Video

Characters est un groupe contenant vos deux objets c’est Ă  cause de ça que les deux bougent en mĂȘme temps.

Wiki : Qu’est-ce qu’un groupe

Seuls les personnages jouables sont dans le groupe, pas l’IA ennemie.

Sur Angie vous avez surement le comportement “top-down”, vous n’avez pas dĂ©sactivĂ© la case des touches par dĂ©faut. C’est touche qui bougent l’objet sont les touches WASD ou/er les touches flĂ©chĂ©s.

Apologies in advance for using English in the French forum.

In the video you said both characters have top down behaviours. If that’s the case, uncheck the default controls setting on Angie.

1 Like

Merci, c’était le problĂšme! J’ai appris quelque chose aujourd’hui. J’espĂšre que cela n’a pas poussĂ© autre chose hors de mon cerveau. Peut-ĂȘtre que demain je ne pourrai pas attacher mes chaussures!

Hey MrMen! Good to see you! A lifesaver as usual! I finally gave up on having the AI patrol back and forth. It was becoming a lifelong pursuit in itself. I think it’s OK for the AI to just be idling. I’m not even going to get rid of the GoRight & GoLeft obstacles, just hide them, for fear of creating new problems! Sorry I have a bunch of questions. I haven’t seen you in a while, and you are the ultimate GDevelop guru! So at the moment, the only animation the enemy uses is her idle, even when she attacks the playble character. I do need to have her using her other animations, when the “seeyou” variable comes into play (playable character approaches), and she goes after the playable character. Any idea how to do that? After that I’m going to try to set up shooting for the playable character. If the playable character shoots the enemy, on to Scene 2. If the enemy comes into contact with the playable character, back to the beginning of Scene 1. Once all that is done, I would like to duplicate Scene 1 for Scenes 2 & 3, since the maps are just a little different, and the AI just needs to be changed. If I duplicate a scene, does it duplicate EVERYTHING: the events, the characters, their behaviors & variables, etc.? Lastly, is putting obstacles around the edge of each scene the best way to keep the characters from going off the edge of the screen? As you know, I have pretty much zero development skills, but I make good cut scenes, so I’d be happy to help with that in your games if you like!
Best regards, Bill Carey

You’ll have to set the attack animation when she attacks, and the move or idle animations depending on the value ‘seeyou’ variable gets set to. None of this appears to be happening in the code snippet you provided.

You’ll also want to determine the direction the enemy is moving, and use the appropriate animations.


Take a look into using external layouts. They define the layout of the game objects without the having any code behind or variables. Effectively you have one base scene with variables, objects and events, and you use the external layout to define the placement of the graphics. This is perfect for multiple levels of the same style of game and the bonus is there’s no code/event duplication.


Try it and see. The best way to learn coding with GDevelop is to give an idea a shot, and if it fails try another angle. But as I wrote earlier, external layouts appear to be a better option.

OK, thanks for all the info. I just tried duplicating Scene 1, so as not to start from scratch with Scenes 2 & 3, and the answer is yes, it does duplicate EVERYTHING. What app do you guys use to make videos from your game project? I don’t suppose there is a free, easy-to-use one out there? I don’t care if there is a watermark. I have been using MS Game Bar, and it is totally unsuitable. If I turn on the microphone, I get crazy background noise except when I am actually recording, and the audio in the project just comes thru as faint background noise. If I turn off the microphone, then the video has no audio, period.

I like to use sharex for taking footage of my work

Wow, thanks, perfect! With the Virtual Audio Capturer, including the project’s audio is no problem. And no watermark!

Hey MrMen!
I managed to do Kristi1217’s laser beam eyes, and to prevent the characters from walking off the edge of the scene. But I have absolutely no idea how to make enemy AI Angie go into the correct animation depending upon what angle the playable character is at, relative to her. When the playable character gets over 300 pixels away, Angie can just go back into her whip-cracking idle. Though now I’m thinking, that once Angie’s directional walk animations are functioning OK, if she actually reaches the playable character then the whip-cracking idle will have to come back, because she can’t kill the playable character with a walk animation (even with those high heeled boots LOL).Video

You’ll have to use Angie.TopDownMovement::Angle() to get the angle she’s facing (keep in mind, this could be negative, so 135 degrees is the same as -225 degrees).

To work the angles out, I’d suggest you start a small project and test. Once you get a result, apply it to your main game.

For example, to get you the answer at the start of this message, I used an [almost empty[ existing project, added TopDownMovement behaviour to the sprite called Pivot_Brick, made a text box called debug, added the following single event and played with the arrow keys :

Hello again, MrMen! Please forgive my perpetual confused state! At the moment, I can’t even get enemy Angie, who has topdown and pathfinding behavior, to do any animation other than number “0”, her idle. In the events, when Angie is moving, her animation should change to 1, which is (walk) Left, but it doesn’t. Also in the events, when the “seeyou” variable is 1, her animation should change to (walk) Left, but it doesn’t. I probably shouldn’t have both anyway, right? If I understand correctly, the angle stuff you are telling me to do would be in the action for the condition “the variable seeyou of Angie is 1”? But right now, changing her animation for this condition does not seem to be happening at all.