Hi, good morning.
I’ve seen a lot of questions with related topics but at the end, I’m not finding a solution which I know it will be actually stupid… I’m setting up a 2D scene which has:
A background with a collider2D at the
bottom (the floor).
One zombie acting as a player, you
can move him left and right.
An ord of zombies coming from the
right which are enemies.
I want to allow the player to walk through the enemies and attack whenever he wants. The thing is that when I’m activating the ‘isTrigger’, the player is automatically falling from the platform (because he’s colliding with it, you can see him falling on the photo).
I tried to put Kinematic and yes, the enemies can pass over it and it doesn’t fall but it’s not the objective because with this case you cannot move the player.
What should I do? I feel that I’m wasting too many hours with this…
well there is a solution that comes to my mind but it’s most certainly not the most pretty one:
Give your enemys as well as your normal character each a trigger collider and a normal collider.
Then whenevery ou spawn an enemy you call the function Physics2.ignoreCollision with the normal colliders of your character and the enemy.
This should render all “normal” collisions obsolete and will still enable you to walk on the ground.
The ugly point about this is: You really have to make sure to call an ignore collision between all your players colliders and all your enemey colliders each. If you forget one that will result in strange things and probably will be difficult to debug.
Should in theory solve your problem though.
Good luck with your game, graphics look neat