Bullet Effect

Hey guys! I was wondering how I could do a bullet effect like in Source Engine. I know Source Engine uses a different type of RayCast (I think its RayTracing, I could be entirely wrong). I came up with two methods that might work but have my concerns on both. I would be thankful for some information on how to procede.

Method 1: Bullet Object -
A bullet is sent along the raycast to the hit position and destroys itself as soon as it collides with anything. The major problem: Either I have a very fast Bullet which is hardly noticeable (like in Source Engine). This is more realistic (as RayCast hits the object immediately), but it is very hard for Unity to detect collisions of fast moving objects and the bullet might not be destroyed. Or: I have some slower bullets which are more detectable, but if the object that is hit moves, the bullet might go somewhere else and just look unrealistly. Maybe someone knows how to get Unity to detect fast bullets?

Method 2: Draw Line -
I also had Draw Line in mind, as it hits the hitpoint in perfect synchronization with the raycast, but also looks unrealistic because there is not movement, its just a line.

Anyway, you have seen my ideas, please feel free to share any of your own or improvements of the ones I have and opinions on which you think would work the best or easiest.

Raycast will detect an intersecting collider between the origin and the target distance (which could be a long distance).

In either case you’re asking for, it’s what you want.

For an instantaneous bullet, Raycast from the muzzle (or other appropriate location near the pawn for the player in question) in a direction according to the facing of the weapon and a distance sufficient to cover a reasonable shot range. The first collider hit will be reported. If you need to allow for bullet penetration, use RaycastAll and sort by distance, then handle penetration according to your algorithm for penetration.

As for traveling bullet (like if you want them to leave tracers) then just make the bullet a tracer graphic and still make it extremely fast. Raycast from the last known position of the bullet to the new position (An easy way would be to place an empty at the last location and then using LookAt to look at the current position - then raycast according to the difference in distance between the positions)

I would freeze game time (I.e players and other entities are frozen for bullet cut scene) and then “ride” the bullet with your camera, at a nice slower speed, until it collides. I’d cut the audio so people get the time concept. It is bullet TIME after all :stuck_out_tongue: