[Solved] Multiple enemys in motion with the same behaviour but independent

What is:
Pick a random object ?
Pick all objects ?

My problem is…
I have created an enemy, added animations and coded everything and all looks good
The behavior of the enemy is like that …

1- If the enemy is away put him in “idle”
2- if you’re close to him he changes his animation to “run”
3- if he is very close to you then he changes his animation to “attack”

Now all of this works on 1 single enemy as you can see here …
But if I add 2 enemies of the same kind, it doesn’t work the way it should and looks buggy as you can see here…
Now I tried using pick a random object thing (I don’t know what it means but I know it has something to do with that… I think)
Also tried using for each loops and it doesn’t work too

What I need is to make each enemy separate with the same behavior
Move and act the same as it was with just 1 enemy …

Hope anyone can help me with this because I have been trying for hours and I’m starting to hate life :smiley:

1 Like

Prefer use behavior system. You can create your own behavior.
It’s more easy to use this system because it’s looped for each instances of object who have the behavior.
Each object with a behavior acts individually.

In your event i guess it’s because one of ennemys is already near Miko, then all the ennemy move but the engine is fast and execute left and right very fast for each ennemys, so nothing move proprely.

And here you use “scene timer” for use attack on your ennemys, but this timer is same for all the ennemy because it’s scene variable then all ennemy attack is same time, prefer use “object timer”.
With this “object timer” each ennemy willl have a different timer.
This allows enemies to be out of sync on attacks


Hey Bouh thanks a lot for your help and yup object timers it is, Kink helped me fix it and I finally managed to fix it along some small bugs but it’s still a bit messy (from codes perspective) and I think I need to learn this behavior thing to make things a little cleaner.
Never used it before so I hope I will understand it…
anyway it works! and that’s what matters for now…

Thanks again!

Cool :slight_smile:
Think to post the solution :wink:

1 Like

Oh yeah sure i was updating some stuff and I did it even without the timers at all, so yeah it was for each loop after all!
works great now :slight_smile: