- Home /
What's the best way to keep an object from falling off of something?
I have an enemy that charges at the player (the game's 2D by the way) and the code I'm currently using to keep enemies from walking off platforms isn't working because they're going too fast. So what is a good way to keep a fast moving enemy from running off something.
The best way might be to just let them fall. Luring enemies to charge to their doom could be part of the game.
Or, could let them start to fall, but them have them slowly glide back to the edge. So "lure off edge" is still a strategy, but not an "I win."
I think I will make it so that when they are charging they can fall off. but when they are walking they won't be able to fall off.
I think I will make it so that when they are charging they can fall off. but when they are walking they won't be able to fall off. thanks for the help owen
Answer by MrMatthias · Aug 25, 2014 at 09:28 PM
invisible colliders
the one problem with this is that I would want it to only affect the enemies and not the player
Colliders can have layer specific collision, go to edit->project settings->physics and then you will see a series of tickboxes, these deter$$anonymous$$e what layers collide with other layers. You can manipulate these, make a layer which only collides with the enemy layer. Its pretty easy to accomplish.