Help with shaking effect

In the enemy-2 code there’s a bug that causes them to stutter when their on the same x or y position. Any suggestions for solutions

1 Like

what is this for? I don’t know the game but I’m assuming you’re trying to put them on the same spot and they are solid so they are pushing each other. If they don’t need to be solid turn that off and see if that fixes it.

If it happens when they’re on the same line (e.g. having one at X:100 Y:200 and another at X:100 and Y:400) then it is something in the code. If I had the game link I could check it out.

game

my problem is when enemy-2 moves towards the player and their on the same x or y axis enemy-2 shakes as it keeps going back and forth trying to chase the player

camera shake example

I know exactly what’s happening, this happened to me before. Doing this will fix it, the Red and Green boxes are what I added. (There are other ways to fix this, but this is the easiest)

What’s happening is that the enemy position is changing between 1 below or 1 above the player position, so I put it into an expression but minus 3 to make it less than 0 if they are they are equal. Put the value you get from that into a Filter, (it needs to be set as “Less than 0”), if it passes then it turns Off the Switch leading to the velocity, but also puts 0 into the X or Y input depending on which Filter it matches. If it fails it just turns the Switch back on.
This is kinda wrong, look at most recent reply

1 Like

If you have any other problems with your game just ask and I’m happy to help :llama: ← looks like a horse, but it’s a llama (they have no alpaca emoji)

1 Like

Wait that’s wrong don’t do that!

This is correct

Do this for both the X and Y.

It’s the same as before, but it adds a Switch, a Filter, and an Expression.

1 Like