Arcade Physics and colliders

I'm doing a top down space shooter type game, and I need the player to react to everything in different ways.

  • For walls, collide and stop movement (unity handles this well with a primitive collider for the wall)
  • For projectiles, damage and brief invulnerability(which is easily handled with scripting), but I do not want the player to be pushed in any way at all, but I still need to detect the actual collision
  • For enemies, I'd like a slight bounce of each other, but nothing too crazy(maybe larger enemies not moving at all)

So what are the best colliders to use? I've tried primitive + Rigidbody with isKinematic = true, this gets me close, but I go right through static walls, and movement with transform just doesn't seem as smooth as adding a force to a rigidbody. Sorry if this question seems long.

Just a thought on the player-projectile collision: From what I've seen in other engines --> a problem that the high speed of the projectile could be an issue that it could actually pass through the player/target/etc. between two frames (or physics steps) and collision is not registered. How about ignoring collision (link) between projectile and player and casting a ray instead and triggering your damage and invulnerability this way? Just a thought, so don't mind me if that's not what you want.

I'd probably do this:

Walls

Yes, primitive colliders are good. Also good is the ‘mesh’ collider, with its ‘static’ setting enabled, if your environment is built in an external 3d app. If your environment has complex geometry, you might find that you want to use simpler invisible ‘proxy’ geometry for the collisions, while still displaying the more complex meshes as the graphics.

Projectiles

If you don’t want the projectiles to actually push the player when they hit, use triggers (as has been mentioned in another answer). You can then apply damage and destroy the projectile in the OnTriggerEnter function. Of course there’s nothing stopping you from also applying a force in that function - eg, if the projectile is supposed to be explosive, there’s even a specific physics function to AddExplosionForce which you could use here.

Enemies

It sounds like you want to create a custom physics material which has a very low value for “Bouncyness”. Just use the “Create” menu in the project pane to create a new one, set your settings, then drag it on to the enemy gameobject. It should automatically be placed into the collider’s material variable.

Hope this covers everything.

You can't use isKinematic = true if you want the object to respond to collisions at all.

Would there be any problem in just using a ridigbody (with isKinematic = false) and moving the ship by applying forces? When your projectiles are triggers they shouldn't cause the ship to move.