I've been working on a cframe bullet drop script, where it creates a ray every so often based on raysPerSecond and metersPerSecond (basically studs per second.) The issue is that when i increase the raysPerSecond, the "bullet" drops a lot faster than a lower raysPerSecond. When the raysPerSecond is set to 6, it gives me roughly the right travel time to bullet drop, but when I increase it, it drops a lot more compared to its travel time. Here's the script:
01 | local plr = game.Players.LocalPlayer; |
02 | local char = plr.Character; |
03 | local m = plr:GetMouse() |
04 |
05 |
06 | local metersPerSecond = 500 ; |
07 | local raysPerSecond = 30 ; |
08 | local dropPerSecond = Vector 3. new( 0 , - 30 , 0 ) |
09 | local maximumDistance = 1000 ; |
10 |
11 | function fire() |
12 | local metersPerRay = metersPerSecond/raysPerSecond; |
13 | local raysGenerated = 0 ; |
14 | local function generateRay(startPosition, direction) |
15 | raysGenerated = raysGenerated + 1 ; |
I tested your code by creating a new part at the end of every ray. I didn't notice any change in changing raysPerSecond to a constant until I tested changing it in metersPerRay. To fix this, you can just change raysPerSecond in line 12 to a constant.
The problem this leads to is found in line 16:
local bulletPath = Ray.new(startPosition, direction*metersPerRay)
The bulletPath will be shorter if you increase raysPerSecond, which in turn causes the bullets to fall faster because generateRay is called more often before finding a part.