Barrier

How would I create a barrier that enemies could walk through but the player couldn’t.

thanks

Animate the enemies ‘going through it’, they won’t need to be able to fight or anything because the player won’t be there. This isn’t a solution, but a workaround.

you could add an invisible barrier above the 2d layer of movement and change the player’s collision mesh so it collides with the invisible barrier above. The enemies’ collision meshes must not extend up to the invisible barrier above.

I really like Omni’s suggestion, another is make a pile a rubble or a wood pile that has a 45 degree and a 90 degree side. And have the part that is vertical on the out side and the slant is where the enemy walks up.

Make a rectangle that is a ghost and make a rectangle that is a static actor and is invisible,Which comes
down in the ghost rectangle when the player comes near and goes up when the player goes away.

As a possible last resort, do the physics and movement yourself. If you program basic movement and locking to the Z position of the ground, you can have enemies move through whatever you want them to move through.

While it is true that such a thing isn’t completely straightforward in the BGE due to the lack of collision layers, I would make the barrier a ghost object and use game logic to stop the player if it is detected by one or more ray sensors, the enemies would then be able to go through without the need of special animations, bounding tricks, and manual physics.

Go with Ace’s suggestion, it makes the most sense and should be the simplest to set up.

Agree with SolarLune, definatley go with Aces suggestion.

A little demo:

Attachments

PlayerBarrier.blend (82.1 KB)