Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is this an efficient way to handle bullet travel on the server?

Asked by 4 years ago

Using raycasting every frame on the server, I'm aware this completely ignores the size of the bullet. If I wanted to incorporate that would it be wise to just unanchor the bullet and use velocity with a touch listener? Or I could incorporate EgoMoose's Region3 module. Any ideas?

01---@param origin CFrame
02    ---@param whitelist table<int, Instance>
03    function Class:Launch(origin, whitelist)
04        local start = tick()
05        local raycastParams = RaycastParams.new()
06        raycastParams.FilterDescendantsInstances = whitelist or {}
07        raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
08        raycastParams.IgnoreWater = true
09 
10        local result = nil
11        local yVelocity = 0
12        while tick() < start + self.Lifetime and not result do
13            local step = RunService.Stepped:Wait()
14            local gravity = (workspace.Gravity / 196.2) * 9.807
15            local drop = (gravity / 2) * math.pow(step, 2--drop = gravity/2 * t²
View all 40 lines...

2 answers

Log in to vote
1
Answered by 4 years ago

I would personally use a BodyPosition with a touched event to handle this, you can probably also use the touched event with the tween service which is easier to work with. Raycasting is better in order to predict a target rather than for collisions

0
I don't think the touched event fires when the projectile is anchored, also a BodyPosition is not good for this at all Valenthian 130 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Your script doesn’t work because the function is not local.

Answer this question