Shooting in Unity, Raycast or Gameobjects?

Hello!
I am quite new to programming at all, and so far i am making a little Shooter based on Brackeys Multiplayer FPS Tutorial on Youtube.
For shooting, he is using the Raycast, as it is - as far as i saw - quite usual.
Now I am wondering, if an alternative to raycast would be simply creating GameObjects, such as bullets, spawning at the player and getting a force towards the direction the player looks at.

I think it would be a cool way for possible power-ups, like creating a slow-mo field where bullets are very slow, etc.

Is there a reason, most shots are made through raycast instead of the way i just told?

Yes there is a reason. I do both though I create a bullet / projectile for a visual effect, and then and I have a script on the projectile do the raycast. The reason raycast is done is because projectiles can move so fast in a game that between frames they can skip over the point they were supposed to collide with. You can mess with the collision detection type on colliders but that can give mixed results where as the raycast technique seems fool proof.

1 Like