What systems should i use for making gun hit registration?

So I’ve been wanting to make a game with guns for awhile now however I’m not sure what I’m supposed to do when it comes to hit registration, I’ve heard about raycasting but I’m not sure where to start with that but I’ve also seen projectile based and hitscan. The game im thinking about implementing this into is a pvp based arena shooter so I’m wanting opinions on what I should do and where to start.

6 Likes

It depends on what style of game you’re aiming for. Simpler FPS games such as CSGO use hitscan and the game itself becomes very competitive and arcade-like. More complex war simulators such as World of Warships and War Thunder use actual projectile motion and terminal ballistics to simulate shells and how they damage/react to vehicle armor. In the middle, you got games like Fortnite that simply add bullet travel time and gravity drop; the terminal ballistics is still a hitscan but it adds some challenge with shooting across long distances.

Frame_1b_V04_eng_small.gif

Just remember, Roblox is still filled with kids and kids do not like very complicated game mechanics. Unless your targetted playerbase are larpers, you generally want to stick with either hitscan and/or simple bullet drop. Take for example Arsenal and Phantom Forces, with Tanmk being the advanced kind.

8 Likes

Thanks for the projectileBallistics demo, really appreicated it

2 Likes

The type of fps im making is similar to Destiny 2 pvp in the crucible so i assume i should go with something like hitscan

2 Likes

Roblox recently released a tutorial on making a laser tag type of game:
https://create.roblox.com/docs/tutorials/gameplay-scripting

And here is a link to the full game that you can edit in studio:

3 Likes

It depends of how you want the game to be, realistic games like milsims will register the direction of the weapon and the distance, like snipers that the bullet loses force after some time, or if its a arcade shooter like Counter Strike or Valorant it will just register where your mouse is pointing at and will hit where you pointed.

1 Like

honestly you might just want hit scan for things like shot guns, smgs, pistols and rifles. But snipers with bullet drop and travel time and rocket launchers with projectiles. It seems to be the most common. How ever a lot of games are doing that. Maybe you can stand out by making all your weapons not have any bullet drop. it could be fun!

Is there any guides or documentation out there for creating hitscan based hit registration?

1 Like

I’m sure you could find some, but for the most part it is as simple as using Workspace:Raycast()

WorldRoot:Raycast

Essentially, when the bullet is fired, cast a ray with origin at the tip of the gun’s barrel, and with the direction of the gun. You can then do something as simple as checking to see if RaycastResult.Instance is a descendent of a player character, and if it is, trigger a remoteevent to cause them damage. The only downside to this approach is that it makes it easy for exploiters to break into the system and apply damage to people as they please using the event.

If you want to be more “safe,” as in safe from exploiters, you could trigger a remoteevent when the gun is fired that contains the origin, direction. Then on the server, you could do the raycast and apply the damage. The only problem with this approach is that latency could cause frustration because players would appear to hit another player on their screen, but not actually have hit.

2 Likes

I feel like you could do the first solution but add server sided checks to counteract the exploiters and latency

Get the clients shooting start position lets just say its the head. Fire a ray on the client and see if it hits. If it does fire the server the clients Hit position of the mouse. If its a vector3 then continue. If it isn’t return. (Just for errors and some people trying to error out the server)

Then fire a ray on the server from the shooting point of the player (the head) and the claimed hit point.

If the server ray hits the player count it as damage. If the servers raycast hit point is CLOSE to the player count it like around 6 studs away or less. To account for ping. This is only one way you can help prevent cheaters although this wont completely stop them it makes their cheats less powerful. You can also make checks for the guns fire rate. If the gun just fired and it has a fire rate of 1 second check on the server. If the client sends a request to fire again from that same weapon under the fire rate time ignore it. So they cant just spam.

I guess considering now after roblox has partnered with synapse this could deter most if not all low level cheaters from exploiting and sounds pretty easy. And when you talk about the firing point and use the head as an example would i just use the guns tip of the barrel instead?