@rbxts/fast-cast
v1.0.0
Published
FastCastRedux (by Eti the Spirit) packaged for roblox-ts — hitscan-based guns with simulated projectile physics
Maintainers
Readme
@rbxts/fast-cast
FastCastRedux by Eti the Spirit, packaged for roblox-ts.
The Luau source is shipped verbatim (no transpilation), with hand-written TypeScript declarations on top — so runtime behavior is identical to the original module.
Installation
From a local checkout:
npm install /path/to/fast-castOr publish/install from a registry as @rbxts/fast-cast.
Usage
import { Workspace } from "@rbxts/services";
import FastCast from "@rbxts/fast-cast";
// One caster per gun. NEVER create a caster per bullet.
const caster = new FastCast();
const params = new RaycastParams();
params.FilterType = Enum.RaycastFilterType.Exclude;
const behavior = FastCast.newBehavior();
behavior.RaycastParams = params;
behavior.Acceleration = new Vector3(0, -Workspace.Gravity, 0);
behavior.MaxDistance = 1000;
caster.LengthChanged.Connect((cast, lastPoint, rayDir, displacement, segmentVelocity, bullet) => {
// Move your cosmetic bullet here.
if (bullet) {
bullet.CFrame = new CFrame(lastPoint.add(rayDir.mul(displacement)), lastPoint.add(rayDir.mul(displacement + 1)));
}
});
caster.RayHit.Connect((cast, result, segmentVelocity, bullet) => {
print(`Hit ${result.Instance.GetFullName()}`);
});
// Fire: origin, direction, speed (or a velocity Vector3), behavior
caster.Fire(origin, direction, 500, behavior);Notes
FastCast.DebugLoggingandFastCast.VisualizeCastsare static toggles for debugging.behavior.CosmeticBulletProvidermust be a real PartCache instance (e.g. from@rbxts/partcache) — FastCast validates it at runtime via its metatable.- The
CanPierceFunctionmust never yield.
