# @rbxts/projectile-cast

> Simple projectile package based off of @rbxts/projectile.

Latest version **2.0.1** (published 2022-03-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install @rbxts/projectile-cast
pnpm add @rbxts/projectile-cast
yarn add @rbxts/projectile-cast
bun add @rbxts/projectile-cast
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2022-03-15 |
| First published | 2021-10-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 18 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | OminousVibes |
| Maintainers | ominousvibes |

## Links

- npm: https://www.npmjs.com/package/@rbxts/projectile-cast
- npm.io page: https://npm.io/package/@rbxts/projectile-cast

## Dependencies (1)

- [@rbxts/goodsignal](https://npm.io/package/@rbxts/goodsignal.md) ^0.2.0

## Recent versions

- 2.0.1 (latest) — 2022-03-15
- 2.0.0 — 2022-03-15
- 1.3.6 — 2021-10-14
- 1.3.5 — 2021-10-14
- 1.3.4 — 2021-10-10
- 1.3.2 — 2021-10-10
- 1.3.1 — 2021-10-10
- 1.3.0 — 2021-10-09
- 1.2.8 — 2021-10-09
- 1.2.7 — 2021-10-09
- 1.2.6 — 2021-10-09
- 1.2.5 — 2021-10-08
- 1.2.0 — 2021-10-08
- 1.1.0 — 2021-10-08
- 1.0.6 — 2021-10-08
- … 6 more at https://npm.io/package/@rbxts/projectile-cast/versions

## README

# @rbxts/projectile-cast
Simple projectile package based off of @rbxts/projectile.

Create a projectile using the following options:

## **Configs**

### `Acceleration?: Vector3;` ( Defaults to 0, 0, 0 )
The constant force applied to the projectile.

### `Bounce?: boolean;` ( Defaults to false )
Whether the projectile should bounce

### `Penetration?: boolean;` ( Defaults to false )
Whether the projectile can penetrate through objects in the world

### `Resistance?: number;` ( Defaults to 1 )
The amount of resistance applied during a penetration

### `MinExitVelocity?: number;` ( Defaults to 100 )
The minimum exit velocity of the projectile. If the calculated exit velocity in a penetration is less than this value, the projectile will be destroyed.

### `CanCollide?: boolean;` ( Defaults to true )
Whether the projectile can collide with other objects (whether it should check for collisions)

### `PhysicsIgnore?: Array<Instance>;` ( Defaults to an empty array )
The list of Instances (and their descendants) to ignore during all physics calculations

### `Duration?: number;` ( Defaults to 2 )
The maximum lifespan, in seconds, of the projectile

### `MaxRange?: number;` ( Defaults to 5000 )
The maximum distance, in studs, that the projectile can travel

### `Renderer?: IRenderer;` ( Defaults to a white CylinderRenderer )
The renderer for the projectile

Simple demo:
```TS
// main.client.ts
import { Projectile, CylinderRenderer } from "@rbxts/projectile-cast";
import { Players } from "@rbxts/services";

const SHOT_COUNT = 3;
const MIN_SPREAD_ANGLE = math.rad(0);
const MAX_SPREAD_ANGLE = math.rad(10);

const random = new Random();

const mouse = Players.LocalPlayer.GetMouse();

let tag: object | undefined;

mouse.Button1Down.Connect(() => {
    const myTag = {};
    tag = myTag;

    while (tag === myTag) {
        const character = Players.LocalPlayer.Character;
        if (!character) break;

        const head = character.FindFirstChild("Head");
        if (!head || !head.IsA("BasePart")) break;

        const position = head.CFrame.Position;
        const endPos = mouse.Hit.Position;

        for (let i = 0; i < SHOT_COUNT; i++) {
            const velocity = new CFrame(position, endPos)
                .mul(CFrame.Angles(0, 0, random.NextNumber(0, 2 * math.pi))) // roll to a random angle
                .mul(CFrame.Angles(0, random.NextNumber(MIN_SPREAD_ANGLE, MAX_SPREAD_ANGLE), 0))
                .LookVector.mul(75);

            const Bullet = new Projectile(position, velocity, {
                Acceleration: new Vector3(0, -50, 0),
                Bounce: true,
                Penetration: true,
                MinExitVelocity: 50,
                PhysicsIgnore: [character],
                Duration: 4,
                Renderer: new CylinderRenderer(Color3.fromHSV(math.random(), 1, 1)),
            });
            Bullet.Touched.Connect((rayResult: RayResult) => {
                print(rayResult.Instance);
            })
        }
        task.wait(1 / 30);
    }
});

mouse.Button1Up.Connect(() => (tag = undefined));
```

---
_Source: https://npm.io/package/@rbxts/projectile-cast · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
