How do I make enemy Movement That moves enemies back and forth in a group?

I am really confused about how to get them to move in the right pattern so the enemies don’t get stuck on the wall?

1 Like

If that doesnt work make the collision delay to 4

1 Like

okay, that’s not what I asked for at all I want to make enemies move in a sacernized pattern.

1 Like

For having a ton of enemies, I suggest using a several Globals that all the enemies would use to move at the same time.

3 Likes

There is one issue it only dose the flip one time and dose not do it multiple times?

1 Like

I was thinking about something like Galaga enemy movements. You’ll need to send a link to your game if you need better suggestions to what your trying to make.

1 Like
1 Like

Any suggestions? I am very confused because it only flips it once.

1 Like

Lol, this is not gonna work :joy:
image
The timer only sets once. Besides, there’s a better way to do this. I’ll show you.

1 Like

First, delete the timer thing. Attach a global variable to the number 1 and name it Speed. Attach the variable to the velocity. Drag out two collision blocks, and get rid of “Wall 2”, because you don’t need it. Your code should look like this:


Next up, set both of the collisions to collide with “Wall”. Set the top one to collide on the left of the wall, and the bottom one to collide with the right. Drag out two numbers and set one of them to 1, and another one to -1. The -1 should be linked to the bottom collision, and the 1 should go on the top. Link the numbers up to the “Set” of the global variable. Also, delete the Always next to your number one. This makes it so that your velocity is always one, and we don’t need that. The code should look like this:

How does it work? All the enemies are reading off of a “Global Variable”, which can either be a number or text element shared throughout all of the same object. You can also put this variable in other objects’ code, which allows it to access the number. Once one object changes the number, it also changes all the objects’ numbers. This basically makes it so that when the enemy collides on the right side, it sets the speed variable to -1, and vice versa. The global variable is automatically read in all the other objects attached to it, and their velocity changes.
How can you take this a step further? In the original game, whenever the enemy hit a wall they would go down a little bit. Can you do this? I’ll give you a hint: Use the position block instead of the velocity for this one.

Stay Swanky,
T+L Studios

3 Likes

thanks but there is one problem it only does it once

2 Likes

No
It
Doesn’t
If
You
Actually
Listened
To
My
Instructions

1 Like

The first collision needs to just be set to left, and the second just needs to be set to right.

image

3 Likes

it will not work still I think might have a bug

2 Likes

Its working for me, did you fix it?

3 Likes

yes I did I just restarted my pc and It works I had it right it was just bugging out on me

3 Likes

Glad you found the solution. Unfortunately, it sounds like you use windows -1, so that’s an oof. Keep making the game, keep asking for help, and eventually you’ll be a pro. I was a noob not all that long ago, you know.

2 Likes

Hihilogic versus JR_01, who will win in the battle of the helper?

Find out next time on… THE HELPERS

2 Likes

Well, JR_01 did help me with my janky-ass manual save function :upside_down_face:

2 Likes