Different approaches to bullet shooting physics in Unity
Projectile Based Movement
This is basically moving a projectile using either the rigid body or just by changing its transform position. This approach is a very common one that heavily relies on the unity collision detection system using either colliders or triggers.
Pros
- It works straight out of the box and it's easy to implement
- Since it uses the rigid body component you can make complex physics patterns easily
- It is generally advised to be used in slow-moving projectiles, RPGs, grenades and homing missiles
Cons
- It is bad for fast-moving projectiles, as bullets seem to pass through the wall, a fix for this I found is by using a raycast script to always check if the object has passed through and object.
- It is performance heavy once you have many of them running at once. A way to help with this is to store the projectiles spawned transform into a list of structs and then move then using that
Hit Scan
This is shooting a raycast and then applying damage to where the raycast hits
General Guidelines
- It is good for fast-moving bullets
- You should use tracers to show the effect of the bullet moving
- Tracers can affect the time in which the bullet gets there hereby adding a bit of delay which is good
- It would be complex to add more variations to the bullet movement as it opts for a more linear precise hit
- Tracers can be faked but at the dispense of the hit happening before the bullet touches the object