I googled it a lot but i was unable to find a solution to this.
i have an enemy and i attached Rigidbody2D to it, it patrols an area and has to go up and down slopes, that’s why the rigidbody2d is attached, to use gravity.
At the same time a want to use with it a CircleCollider2D as a trigger, to have combat.
I need my player to pass through this enemy.
But at the moment i set the collider as a trigger my enemy falls through the floor.
The floor also has a composite collider on it and a rigidbody2d.
There is any way to work around this?
ps: i’m using c# if i need any coding.
If an object is having a collider with IsTrigger enabled, it will not act as a solid shape even though the rigidbody is attached. Instead it will work as a trigger volume. What you can do is:-
Create an empty child of player
Attach another CircleCollider2D to it and mark it as isTrigger enabled.
Use this for triggering the enemies.
Disable the isTrigger of the players main collider.
EDIT: sorry i missed the Enemy Part. For that you can add different layers to Player and enemy. You can check here. Now got to the project settings->physics2D and disable the collision between the Player and the Enemy layers. In this way, they will not collide with each other.
Thx for your reponse.
I’ve already tried to do this, but the problem is that my player pushs the enemy and i can’t pass through it.