Making a combat game with ranged weapons? FastCast may be the module for you!

Hey there, the bullets appearing far away is due to extremely long ray lengths for extremely high speed projectiles.

This is also tied in with the update loop problem that was mentioned previously somewhere in this topic. I have tried to do simulate(cast, 0 (deltatime), false) after the simulation connection to try and position it at the start but that had a lot of issues.

Ended up this hack from a previous post to position it at segment origin instead (bullet position in the past) and a lot of task.waits() for another issue (point blank shots)

Perhaps one day there could be some advanced task scheduling done perhaps 2 Runservice events in heartbeat and one in stepped. Maybe even task.defer().

But solution seems to work as is and the rest of the module works great :+1:.

The projectile is spawning ahead of its origin point for me, and this makes the trail look horrible. Anyone know what to do to fix this?

is it possible to change the speed of a bullet when penetrating through a wall? cause i got no clue how. (unless its the velocity thing i see in the variables of certain functions)

Blacklist in Raycast params is decrapted it says on the debug gun you provided

Is there any way to perfectly validate a cast? I tried using the start and end positions with a projectile motion equation and using tick() to log the start and end times of a cast and using them for t, but the results seem to differ by a good ±10 in the position compared to the simulation.

local function projectileMotionEquation(g, v, initialPosition, t)
	return 0.5 * g * t ^ 2 + v * t + initialPosition
end

I am not going to maintain FastCast but I do have this if FastCast where to ever break. (I think FastCast is in a pretty solid state I would not expect it to break for a while… a long while…)

Have you figured this out by now? Much appreciated if you have and could share.

I think i just suck, though I could not understand this. :rofl: :rofl: :rofl: :yawning_face: :yawning_face: :yawning_face: :triumph: :triumph: :triumph:

It doesn’t seem to be possible :frowning:

How do you handle replication?

Is there a way to combat bad hitreg with moving npcs. some of the projectiles just go straight through the npc on the client

Do I must make a new caster (server script) for each gun the players have? (for example, 10 players - 10 server scripts)

Or can I have one server script handling all players’ shootings? (10 players - 1 server script but 10 local scripts)

how would I go about using this for a model rather than a part?

1 server script. Just use remote events and have that 1 script do the casting and damaging.

1 Like

I have a quick question. How can I change my projectiles’ colors on 1 caster instead of having individual casters have different colors because it causes lag. I have tried changing it from the projectile container and then tried taking it out, changing the color, and putting it back it but also didnt work some how. Is there a sort of way to change the custonprojectiles’ color with only 1 caster? Or is there no way?

Hey, did you ever get around latency compensation? I was just about to program this but took a look at DevForum just to make sure it wasn’t done already…

Seems like you just need some API surfaces to accelerate the simulation to any point in time.

Probably need API surfaces along the lines of:

  • ActiveCast:PredictHit(): Vector3? - Fast forward all the way to the end of trajectories so server can see what the predicted hit location is ahead of time
  • ActiveCast:GetPositionAtTime(time: number): Vector3? - Get position at t seconds after cast start time
  • ActiveCast:GetPositionAtTick(tick: number): Vector3? [Bonus] - Get position at a unix timestamp

Is there a GitHub repo where I can submit a pull request if I end up writing this into the library for my own project?

2 Likes

This module is still incredibly useful, though it’s a shame that it’s no longer being developed. I wish someone would extend it to work with parallel lua as I imagine it would improve performance a bit.

Will this work with hitscan guns or just projectile?

this is meant to be a way to simulate projectile physics, if u only need hitscan u should not use this module