Author Topic: Game maker-How to make enemy walls?  (Read 4885 times)

For my ICT class we are using game maker as part of our course. I have my enemies moving side to side, however, I don't want enemies falling off the platforms. So, I decided to make invisible walls at the edge of the platforms. This prevents them from falling off, but the player cannot walk through them. How can I change it so that the player can walk through this object, but the enemy cannot?
« Last Edit: March 05, 2013, 07:10:22 PM by Muzzles56 »

Check what the object colliding with it is before you do the actual collision bit.

Check what the object colliding with it is before you do the actual collision bit.
The object is just a 1x2 invisible sprite with solid properties

I'm sure that doesn't really change much. I don't know anything about the newer game maker though :(
« Last Edit: March 05, 2013, 07:17:17 PM by tails »

The object is just a 1x2 invisible sprite with solid properties

he means from a logic perspective.

an entity collides with a wall
is the entity a player? --> do not restrict the player movement
is the entity a monster? --> stop the monster from moving (and probably turn it around if your game is 2D)




there's probably a simple way to do this in game maker but I don't use game maker because using game maker is like using scratch and that's silly.

The way to go about this should not be invisible walls. You are probably making it so they have no AI whatsoever. Make them stop before they fall or actually define the edge as an object, and make them stop as soon as they hit it with no actual collison but a collision box.

I'm relatively experienced with gamemaker.

All you have to do is create an invisible-to-the-player small cube and place it at the edge of the platform.

Then, in the events of the enemy, do something along the lines of

On enemy collide with (whateveryounameit) make enemy... well...

stuff, I can't explain it.

Here's a bit of code from a game I was working on a while ago.

Code: [Select]
Collision Event with object enemy_marker:

reverse horizontal direction

And to give you a better view,



Make sure collision is unchecked on that enemy marker so the player doesn't collide with it.

EDIT2: Oh yeah, and make sure "visible" is unchecked on the enemy marker.
« Last Edit: March 06, 2013, 01:27:14 AM by ResonKinetic »

The way to go about this should not be invisible walls. You are probably making it so they have no AI whatsoever. Make them stop before they fall or actually define the edge as an object, and make them stop as soon as they hit it with no actual collison but a collision box.

if he can't add invisible walls do you really think he knows how to do that

if he can't add invisible walls do you really think he knows how to do that
I think I know how. In theory, anyways.

Thanks, ResonKinetic, I will try that today. If it doesnt work, ill post an update

I can't tell is GameMaker is loving buggy as forget or I'm just doing things wrong, so I gave up on it.

I think I know how. In theory, anyways.

Thanks, ResonKinetic, I will try that today. If it doesnt work, ill post an update
You could also try making the enemies more dynamic by having them check edges themselves. If there is a drop, than there will be an empty space by the side. In the step even, you can use collision_point and check a point underneath the enemy at an offset, so if there is a wall under it, it does nothing. If there ISN'T at wall at the checked point, they change direction.

stuff
Yep, this worked. Thanks a bunch!

You could also try making the enemies more dynamic by having them check edges themselves. If there is a drop, than there will be an empty space by the side. In the step even, you can use collision_point and check a point underneath the enemy at an offset, so if there is a wall under it, it does nothing. If there ISN'T at wall at the checked point, they change direction.
No idea how to do half of that...