[SOLVED]Trouble with boss ai

Ok so i appologize in advance if this is a lot but im really stuck and cant figure this out.

I am trying to make a boss that moves between 3 markers and swings his mace in and out when he gets to each marker.

What ive done so far seems to work on the first marker. After that it doesnt seem to work. He walks past marker #2 but hesitates and keeps going. I just dont undestand what i did wrong. I will attach pics of events and a short video so you can see how its failing








Ok i cant seem to load videos to here… but yeah it workes when the enemy gets to the marker in the middle of the room. He then walks left towards the player but hesitates when colliding with marker 2 and just contiues to walk into a wall. The code is the same for each arrival at each marker.

Please help :frowning:

I will add a video to discord just incase someone checks this quick

There’s a lot to read. Maybe someone else can figure out why it doesn’t work because it’s always good to learn. Here are 2 simpler approaches. I left out a lot of your concept but the basic structure is here. Add or change what is needed.

This uses a tween to move between an object name Marker which has 3 instances with a variable named ID set from 0 through 2. It uses an object variable to tween to each Marker in order. The tween time is based on distance to keep a constant speed regardless of the distance.

A slightly modified version picks a random Marker instead of using an ID. I prefer randomness. It uses the collision to eliminate the current marker as one of the possible next Markers.

I can’t guarantee that this is bug free. The first attempt rarely is perfect. But the concept is solid.

You could replace the tween with pathfinding. You could add more randomness by changing set values for random numbers. For example, the number of degrees the weapon spins.

Both versions can accommodate more markers with just a slight change to the mod(). The random version doesn’t care how many Markers there are.

Thank you so much for the assistance, i will go through your concept and probably try it out shortly.

I shortened a lot of my events and made it a lot less confusing. I think i got it to work. Just one step away from returning to the beginning of my loop. If i succeed i will post my new events that way we have 2 possible solutions to this problem. Yours and fingers crossed mine aswell.

Thanks again

1 Like

You’re welcome. I’ve used this approach before. So, I remember most of the process .

Anytime your events begin to repeat, it can be easier if you use instances, groups, extension or behaviors.

The events: For Each object, for each child and repeat also help. I don’t really like the while event. It has its uses but it’s too easy to get stuck in an infinite loop. Long loops can also cause lag. State booleans are also excellent triggers.

I also don’t like to use wait it’s too easy to get the wait events to stack up plus there are already many events that tell you when something is done like tween finished, reached destination, animation finished and a few others. Those conditions allow for a more precise timing instead of just estimatimg a time. Timers are also helpful. For me, it helps me follow the process. It gives it more structure.

I got it to work, its quite a bit longer than yours but i feel like it will be easy for me to fit in the other actions i want to add as his health gets low and also transitioning from hits back into the pattern i want hime to follow…

Thanks again, i have a character that i am going to use your idea for. Hope you dont mind.







1 Like

I’m glad you got it working. Feel free to use my events as you wish. We’re all here to learn.