How to detect collisions without effecting physics

Hi all, this might be a difficult problem for me to describe, but I will try my best.

My characters and enemies are sprites that use the physics system (ie, there is a rigidbody)
Basically, on my characters and enemies they have two hidden box colliders, one for attack left and one for attack right.

My prefab structure looks a bit like this.

PlayerOne (empty object)

  • Rigidbody (for character control and jumping) (no mesh visible)
  • Main Camera (follows player)
  • Sprite for the main character with animator
  • Light
  • Sound Emitter
  • Attack Left (disabled)
  • Attack Right (disabled)

The enemies look pretty similar to this.

Basically, when the player attacks, it enables the attack left or right collider and then does an OnCollisionEnter() function to detect if it has collided with anything with the tag “enemy”.

The enemy does the same, it just detects the tag “player”

Now at first, when the character was attacking the enemies, it was bouncing us all over the place. I then used a physics material on the collider and reduced everything on it to basically 0. That helped, but I am still finding that the enemies and player can still be bounced around sometimes on collisions, which means the game plays pretty badly.

Is there some way that I can stop the collisions from applying force to the object it collides with?

I hope this makes sense?

Cheers!

Thanks all, its solved by making them triggers and changing to OnTriggerEnter :slight_smile: